Example #1
0
    def __init__(self, samp_per_sym=4):
        gr.hier_block2.__init__(
            self, "PSK31 Modulator",
            gr.io_signature(1, 1, gr.sizeof_char*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )

        self.samp_per_sym = samp_per_sym

        self.connect(
            self,

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

            digital.diff_encoder_bb(2),
            blocks.char_to_float(1, 1),
            blocks.add_const_vff((-0.5, )),
            blocks.multiply_const_vff((2, )),
            interp_fir_filter_fff(samp_per_sym, self._envelope_taps()),
            blocks.float_to_complex(1),
            self,
        )
Example #2
0
    def __init__(self, data_size, enc, dec, threading):
        gr.top_block.__init__(self, "_qa_helper")

        self.puncpat = puncpat = '11'

        self.enc = enc
        self.dec = dec
        self.data_size = data_size
        self.threading = threading

        self.ext_encoder = extended_encoder(enc,
                                            threading=self.threading,
                                            puncpat=self.puncpat)
        self.ext_decoder = extended_decoder(dec,
                                            threading=self.threading,
                                            ann=None,
                                            puncpat=self.puncpat,
                                            integration_period=10000)

        self.src = blocks.vector_source_b(
            data_size * [0, 1, 2, 3, 5, 7, 9, 13, 15, 25, 31, 45, 63, 95, 127],
            False)
        self.unpack = blocks.unpack_k_bits_bb(8)
        self.map = map_bb([-1, 1])
        self.to_float = blocks.char_to_float(1)
        self.snk_input = blocks.vector_sink_b()
        self.snk_output = blocks.vector_sink_b()

        self.connect(self.src, self.unpack, self.ext_encoder)
        self.connect(self.ext_encoder, self.map, self.to_float)
        self.connect(self.to_float, self.ext_decoder)
        self.connect(self.unpack, self.snk_input)
        self.connect(self.ext_decoder, self.snk_output)
Example #3
0
    def __init__(self, data_size, enc, dec, threading):
        gr.top_block.__init__(self, "_qa_helper")

        self.puncpat = puncpat = '11'

        self.enc = enc
        self.dec = dec
        self.data_size = data_size
        self.threading = threading

        self.ext_encoder = extended_encoder(enc, threading=self.threading, puncpat=self.puncpat)
        self.ext_decoder= extended_decoder(dec, threading=self.threading, ann=None,
                                           puncpat=self.puncpat, integration_period=10000)

        self.src = blocks.vector_source_b(data_size*[0, 1, 2, 3, 5, 7, 9, 13, 15, 25, 31, 45, 63, 95, 127], False)
        self.unpack = blocks.unpack_k_bits_bb(8)
        self.map = map_bb([-1, 1])
        self.to_float = blocks.char_to_float(1)
        self.snk_input = blocks.vector_sink_b()
        self.snk_output = blocks.vector_sink_b()

        self.connect(self.src, self.unpack, self.ext_encoder)
        self.connect(self.ext_encoder, self.map, self.to_float)
        self.connect(self.to_float, self.ext_decoder)
        self.connect(self.unpack, self.snk_input)
        self.connect(self.ext_decoder, self.snk_output)
Example #4
0
    def __init__(self, sample_rate, amplitude):
        gr.hier_block2.__init__(self, "gsm_source_c",
            gr.io_signature(0, 0, 0), # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        self._symb_rate = 13e6 / 48;
        self._samples_per_symbol = 2

        self._data  = blocks.vector_source_b(self.gen_gsm_seq(), True, 2)
        self._split = blocks.vector_to_streams(gr.sizeof_char*1, 2)

        self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self._mod  = digital.gmsk_mod(self._samples_per_symbol, bt=0.35)

        self._pwr_f = blocks.char_to_float(1, 1)
        self._pwr_c = blocks.float_to_complex(1)
        self._pwr_w = blocks.repeat(gr.sizeof_gr_complex*1, self._samples_per_symbol)

        self._mul = blocks.multiply_vcc(1)
        self._interpolate = filter.fractional_resampler_cc( 0,
            (self._symb_rate * self._samples_per_symbol) / sample_rate )
        self._scale = blocks.multiply_const_cc(amplitude)

        self.connect(self._data, self._split)
        self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0))
        self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w, (self._mul, 1))
        self.connect(self._mul, self._interpolate, self._scale, self)
    def test_00(self):
        expected_result = (
            0x00, 0x11, 0x22, 0x33,
            0x44, 0x55, 0x66, 0x77,
            0x88, 0x99, 0xaa, 0xbb,
            0xcc, 0xdd, 0xee, 0xff)

        # Filter taps to expand the data to oversample by 8
        # Just using a RRC for some basic filter shape
        taps = filter.firdes.root_raised_cosine(8, 8, 1.0, 0.5, 21)
        
        src = blocks.vector_source_b(expected_result)
        frame = digital.simple_framer(4)
        unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        expand = filter.interp_fir_filter_fff(8, taps)
        b2f = blocks.char_to_float()
        mult2 = blocks.multiply_const_ff(2)
        sub1 = blocks.add_const_ff(-1)
        op = digital.simple_correlator(4)
        dst = blocks.vector_sink_b()
        self.tb.connect(src, frame, unpack, b2f, mult2, sub1, expand)
        self.tb.connect(expand, op, dst)
        self.tb.run()
        result_data = dst.data()

        self.assertEqual(expected_result, result_data)
Example #6
0
	def __init__(self, esno=0, samp_rate=3200000):
		gr.hier_block2.__init__(
			self, "FECTEST",
			gr.io_signature(1, 1, gr.sizeof_char*1),
			gr.io_signature(2, 2, gr.sizeof_char*1))
                
		##################################################
		# Parameters
		##################################################
		self.esno = esno
		self.samp_rate = samp_rate
		
		##################################################
		# Blocks
		##################################################
		self.gr_unpacked_to_packed_xx_0_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
		self.gr_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_LSB_FIRST)
                self.char_to_float = blocks.char_to_float()
                self.float_to_char = blocks.float_to_char()
		self.gr_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate)
		self.gaussnoise_ff_0 = fec.gaussnoise_ff(esno)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_unpacked_to_packed_xx_0_0, 0), (self, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self, 1))
		self.connect((self.gr_throttle_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.gaussnoise_ff_0, 0), (self.float_to_char, 0))
                self.connect((self.float_to_char, 0), (self.gr_unpacked_to_packed_xx_0_0, 0))
		self.connect(self, (self.gr_throttle_0, 0))
                self.connect((self.gr_throttle_0, 0), (self.char_to_float, 0))
                self.connect((self.char_to_float, 0), (self.gaussnoise_ff_0, 0))
Example #7
0
    def __init__(self, ber_block, ncorrelations, lfsr_bits = 16):
        gr.top_block.__init__(self)

        prn_len = 2**lfsr_bits
        prn = np.concatenate((scipy.signal.max_len_seq(lfsr_bits)[0], [1]))
        prn_fft_conj = np.conjugate(np.fft.fft(2*prn-1))

        self.source = blocks.vector_source_b(prn, True, 1, [])
        
        self.ber_block = ber_block
        
        self.char2float = blocks.char_to_float(1, 0.5)
        self.add_const = blocks.add_const_ff(-1.0)
        self.source_vector = blocks.stream_to_vector(gr.sizeof_float, prn_len)

        self.fft = fft.fft_vfc(prn_len, True, window.rectangular(prn_len), 1)
        self.prn_fft_source = blocks.vector_source_c(prn_fft_conj, True, prn_len, [])
        self.multiply_ffts = blocks.multiply_vcc(prn_len)
        self.ifft = fft.fft_vcc(prn_len, False, np.ones(prn_len)/prn_len**2, False, 1)
        self.corr_mag = blocks.complex_to_mag(prn_len)
        self.max_corr = blocks.max_ff(prn_len, 1)
        self.multiply_const = blocks.multiply_const_ff(-0.5)
        self.add_const2 = blocks.add_const_ff(0.5)
        
        self.head = blocks.head(gr.sizeof_float, ncorrelations)
        self.sink = blocks.vector_sink_f()

        self.connect(self.source, self.ber_block, self.char2float, self.add_const,
                         self.source_vector, self.fft, (self.multiply_ffts,0),
                         self.ifft, self.corr_mag, self.max_corr, self.multiply_const,
                         self.add_const2, self.head, self.sink)
        self.connect(self.prn_fft_source, (self.multiply_ffts,1))
Example #8
0
    def __init__(self, data):
	gr.hier_block2.__init__(self, "chars_to_floats",
				gr.io_signature(0, 0, 0),
				gr.io_signature(1, 1, gr.sizeof_float))
        self.src = blocks.vector_source_b(data)
        self.cvt = blocks.char_to_float()
        self.connect(self.src, self.cvt, self)
Example #9
0
    def __init__(self, sample_rate, amplitude):
        gr.hier_block2.__init__(
            self,
            "gsm_source_c",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(1, 1, gr.sizeof_gr_complex))  # Output signature

        self._symb_rate = 13e6 / 48
        self._samples_per_symbol = 2

        self._data = blocks.vector_source_b(self.gen_gsm_seq(), True, 2)
        self._split = blocks.vector_to_streams(gr.sizeof_char * 1, 2)

        self._pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self._mod = digital.gmsk_mod(self._samples_per_symbol, bt=0.35)

        self._pwr_f = blocks.char_to_float(1, 1)
        self._pwr_c = blocks.float_to_complex(1)
        self._pwr_w = blocks.repeat(gr.sizeof_gr_complex * 1,
                                    self._samples_per_symbol)

        self._mul = blocks.multiply_vcc(1)
        self._interpolate = filter.fractional_resampler_cc(
            0, (self._symb_rate * self._samples_per_symbol) / sample_rate)
        self._scale = blocks.multiply_const_cc(amplitude)

        self.connect(self._data, self._split)
        self.connect((self._split, 0), self._pack, self._mod, (self._mul, 0))
        self.connect((self._split, 1), self._pwr_f, self._pwr_c, self._pwr_w,
                     (self._mul, 1))
        self.connect(self._mul, self._interpolate, self._scale, self)
Example #10
0
    def test_ri8_to_ri32(self):

        path = self.make_file("test_source", "ri8", 1)

        # expected
        expected_source = sigmf.source(path, "ri8", False)
        convert1 = blocks.char_to_float(1, 1)
        convert2 = blocks.float_to_int(1, 1)
        expected_sink = blocks.vector_sink_i(1)

        # actual
        actual_source = sigmf.source(path, "ri32", False)
        actual_sink = blocks.vector_sink_i(1)

        tb1 = gr.top_block()
        tb1.connect(expected_source, convert1)
        tb1.connect(convert1, convert2)
        tb1.connect(convert2, expected_sink)
        tb1.run()
        tb1.wait()

        tb2 = gr.top_block()
        tb2.connect(actual_source, actual_sink)
        tb2.run()
        tb2.wait()

        e = expected_sink.data()
        a = actual_sink.data()
        np.testing.assert_almost_equal(e, a)
Example #11
0
 def __init__(self):
     gr.top_block.__init__(self)
     #variables
     self.samp_rate = samp_rate
     self.direction = RC_NOTHING #no direction to start 
     #blocks 
     #define the gnuradio blocks
     #interpolator expands the input function - this creates long zeros and ones  
     self.interpolator = rccar2.functioninterpolator(samp_rate)
     #functioncoder takes a functioncode into it and creates the appropriate command stream 
     self.functioncoder = rccar2.functioncoder(samplerate=samp_rate, functioncode=1)
     #sink (the hackRF in this case), can be changed to your transmitting device of course
     self.hackrf = osmosdr.sink(args="numchan=" +str(1) + " " + "hackhf")
     self.hackrf.set_sample_rate(samp_rate)
     self.hackrf.set_center_freq(RC_FREQUENCY,0)
     self.hackrf.set_freq_corr(0,0)
     #enable the hackrf to transmit (need to set the gain to 14dB) 
     self.hackrf.set_gain(14,0)
     self.hackrf.set_if_gain(30,0)
     self.hackrf.set_bb_gain(20,0)
     self.hackrf.set_antenna("",0)
     self.hackrf.set_bandwidth(0,0)
     #conversion blocks 
     self.float_to_complex = blocks.float_to_complex(1)
     self.char_to_float = blocks.char_to_float(1,1)
     #vector source which sends the direction to the functioncoder 
     self.vector_source = blocks.vector_source_i([self.direction], False) 
     #connect it all up
     self.connect((self.char_to_float,0), (self.float_to_complex,0))
     self.connect((self.char_to_float,0), (self.float_to_complex,1)) 
     self.connect((self.interpolator,0), (self.char_to_float,0))
     self.connect((self.float_to_complex,0), (self.hackrf,0))
     self.connect((self.vector_source,0), (self.functioncoder,0))
     self.connect((self.functioncoder,0), (self.interpolator,0))
Example #12
0
	def __init__(self):
		gr.top_block.__init__(self, "Many Rate Changing")

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

		##################################################
		# Blocks
		##################################################
		self.random_source_x_0 = gr.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True)
		self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(2, gr.GR_LSB_FIRST)
		self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(2, gr.GR_MSB_FIRST)
		self.gr_null_sink_0_2 = gr.null_sink(gr.sizeof_char*1)
		self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, 3, 20, 0)
		self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
		self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

		##################################################
		# Connections
		##################################################
		self.connect((self.blocks_char_to_float_0, 0), (self.blocks_keep_m_in_n_0, 0))
		self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_float_to_char_0, 0))
		self.connect((self.blocks_float_to_char_0, 0), (self.gr_packed_to_unpacked_xx_0, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0))
		self.connect((self.random_source_x_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.gr_null_sink_0_2, 0))
Example #13
0
    def __init__(self,samp_per_sym=1):
        valid_mod_block.__init__(self)

        # Blocks
        self.b_to_f = blocks.char_to_float(1, 1)
        self.interp_filter = filter.interp_fir_filter_fff(samp_per_sym, (np.ones(samp_per_sym)))
        self.f_to_c = blocks.float_to_complex(1)
        
        self.c_to_r = blocks.complex_to_real(1)
        self.decim_filter = filter.fir_filter_fff(samp_per_sym, (np.ones(samp_per_sym)))
        self.divide_f = blocks.multiply_const_vff((1.0/samp_per_sym, ))
        self.f_to_b = blocks.float_to_char(1,1)
        
        # Connections
        self.connect((self,0),self.b_to_f)
        self.connect(self.b_to_f,(self,2))
        self.connect(self.b_to_f,self.interp_filter)
        self.connect(self.interp_filter,self.f_to_c)
        self.connect(self.f_to_c,(self,1))

        self.connect((self,1),self.c_to_r)
        self.connect(self.c_to_r,self.decim_filter)
        self.connect(self.decim_filter,self.divide_f)
        self.connect(self.divide_f,(self,3))
        self.connect(self.divide_f,self.f_to_b)        
        self.connect(self.f_to_b,(self,0))
    def __init__(self):
        gr.top_block.__init__(self, "Many Rate Changing")

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

        ##################################################
        # Blocks
        ##################################################
        self.random_source_x_0 = gr.vector_source_b(
            map(int, numpy.random.randint(0, 256, 1000)), True)
        self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(
            2, gr.GR_LSB_FIRST)
        self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(
            2, gr.GR_MSB_FIRST)
        self.gr_null_sink_0_2 = gr.null_sink(gr.sizeof_char * 1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_float_to_char_0, 0))
        self.connect((self.blocks_float_to_char_0, 0),
                     (self.gr_packed_to_unpacked_xx_0, 0))
        self.connect((self.gr_unpacked_to_packed_xx_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.random_source_x_0, 0),
                     (self.gr_unpacked_to_packed_xx_0, 0))
        self.connect((self.gr_packed_to_unpacked_xx_0, 0),
                     (self.gr_null_sink_0_2, 0))
Example #15
0
 def __init__(self, data):
     gr.hier_block2.__init__(self, "chars_to_floats",
                             gr.io_signature(0, 0, 0),
                             gr.io_signature(1, 1, gr.sizeof_float))
     self.src = blocks.vector_source_b(data)
     self.cvt = blocks.char_to_float()
     self.connect(self.src, self.cvt, self)
Example #16
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Receptor")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 44100
        self.fcdemod = fcdemod = 0
        self.fc = fc = 0

        ##################################################
        # Blocks
        ##################################################
        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_clock_source("gpsdo", 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(fc, 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.digital_psk_demod_0 = digital.psk.psk_demod(
          constellation_points=4,
          differential=True,
          samples_per_symbol=2,
          excess_bw=0.35,
          phase_bw=6.28/100.0,
          timing_bw=6.28/100.0,
          mod_code="gray",
          verbose=False,
          log=False,
          )
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((0.007874016, ))
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 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.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_sig_source_x_0_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fcdemod, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.digital_psk_demod_0, 0))
        self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_char_to_float_1, 0), (self.blocks_multiply_const_vxx_0_0_0, 0))
        self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_char_to_float_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.audio_sink_0, 0))
 def test_char_to_float_identity(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_b(src_data)
     op = blocks.char_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
Example #18
0
 def test_char_to_float_identity(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (1.0, 2.0, 3.0, 4.0, 5.0)
     src = blocks.vector_source_b(src_data)
     op = blocks.char_to_float()
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
Example #19
0
 def test_char_to_float_scale(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (0.5, 1.0, 1.5, 2.0, 2.5)
     src = blocks.vector_source_b(src_data)
     op = blocks.char_to_float(scale=2.0)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
    def __init__(self, RIC=1006370, SubRIC=0, Text='pRIWET'):
        gr.top_block.__init__(self, "POCSAG Sender via HackRF")

        ##################################################
        # Parameters
        ##################################################
        self.RIC = RIC
        self.SubRIC = SubRIC
        self.Text = Text

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 47
        self.symrate = symrate = 38400
        self.samp_rate = samp_rate = 12000000
        self.pocsagbitrate = pocsagbitrate = 1200
        self.pagerfreq = pagerfreq = 473325000
        self.max_deviation = max_deviation = 4500.0
        self.af_gain = af_gain = 190

        ##################################################
        # Blocks
        ##################################################
        self.pocsag_generator = pocsag_generator.pocsagsender(number=RIC, source=SubRIC, sleeptime=5, text=Text)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  float(samp_rate)/float(symrate),
                  taps=None,
        	  flt_size=16)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf' )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(pagerfreq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(0, 0)
        self.osmosdr_sink_0.set_if_gain(tx_gain, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, symrate/pocsagbitrate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((af_gain/100, ))
        self.blocks_char_to_float_0 = blocks.char_to_float(1, af_gain*0.7/1000)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate))



        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.pocsag_generator, 0), (self.blocks_repeat_0, 0))
 def test_char_to_float_scale(self):
     src_data = (1, 2, 3, 4, 5)
     expected_data = (0.5, 1.0, 1.5, 2.0, 2.5)
     src = blocks.vector_source_b(src_data)
     op = blocks.char_to_float(scale=2.0)
     dst = blocks.vector_sink_f()
     self.tb.connect(src, op, dst)
     self.tb.run()
     self.assertFloatTuplesAlmostEqual(expected_data, dst.data())
Example #22
0
    def __init__(self,
                 generic_encoder=0,
                 generic_decoder=0,
                 esno=0,
                 samp_rate=3200000,
                 threading="capillary",
                 puncpat='11',
                 seed=0):
        gr.hier_block2.__init__(self, "fec_test",
                                gr.io_signature(1, 1, gr.sizeof_char * 1),
                                gr.io_signature(2, 2, gr.sizeof_char * 1))

        self.generic_encoder = generic_encoder
        self.generic_decoder = generic_decoder
        self.esno = esno
        self.samp_rate = samp_rate
        self.threading = threading
        self.puncpat = puncpat

        self.map_bb = digital.map_bb(([-1, 1]))
        self.b2f = blocks.char_to_float(1, 1)

        self.unpack8 = blocks.unpack_k_bits_bb(8)
        self.pack8 = blocks.pack_k_bits_bb(8)

        self.encoder = extended_encoder(encoder_obj_list=generic_encoder,
                                        threading=threading,
                                        puncpat=puncpat)

        self.decoder = extended_decoder(decoder_obj_list=generic_decoder,
                                        threading=threading,
                                        ann=None,
                                        puncpat=puncpat,
                                        integration_period=10000,
                                        rotator=None)

        noise = math.sqrt((10.0**(-esno / 10.0)) / 2.0)
        #self.fastnoise = analog.fastnoise_source_f(analog.GR_GAUSSIAN, noise, seed, 8192)
        self.fastnoise = analog.noise_source_f(analog.GR_GAUSSIAN, noise, seed)
        self.addnoise = blocks.add_ff(1)

        # Send packed input directly to the second output
        self.copy_packed = blocks.copy(gr.sizeof_char)
        self.connect(self, self.copy_packed)
        self.connect(self.copy_packed, (self, 1))

        # Unpack inputl encode, convert to +/-1, add noise, decode, repack
        self.connect(self, self.unpack8)
        self.connect(self.unpack8, self.encoder)
        self.connect(self.encoder, self.map_bb)
        self.connect(self.map_bb, self.b2f)
        self.connect(self.b2f, (self.addnoise, 0))
        self.connect(self.fastnoise, (self.addnoise, 1))
        self.connect(self.addnoise, self.decoder)
        self.connect(self.decoder, self.pack8)
        self.connect(self.pack8, (self, 0))
Example #23
0
    def __init__(self, puncpat='11'):
        gr.top_block.__init__(self, "Eve Dec")

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

        ##################################################
        # Variables
        ##################################################
        self.H_dec = H_dec = fec.ldpc_H_matrix('/usr/local/share/gnuradio/fec/ldpc/n_1100_k_0442_gap_24.alist', 24)
        self.samp_rate = samp_rate = 10000000
        self.punc_size = punc_size = 17
        self.punc_pattern = punc_pattern = 131070


        self.pld_dec = pld_dec = map((lambda a: fec.ldpc_bit_flip_decoder.make(H_dec.get_base_sptr(), 20)), range(0,16))
        self.header = header = [0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 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, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0]
        self.erro = erro = 65

        ##################################################
        # Blocks
        ##################################################
        self.scrambler_cpp_additive_descrambler_0 = scrambler_cpp.additive_descrambler(0x8A, 0x7F, 7, 440-8)
        self.puncture64_cpp_depuncture64_0 = puncture64_cpp.depuncture64(punc_size, punc_pattern, 127)
        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_map_bb_0_0_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_repack_bits_bb_0_0_0_1_0_0 = blocks.repack_bits_bb(8, 1, '', 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_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, 1105, 0)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/andre/ELI/'+num+'/EVE_54_8000_BRUTO.txt', False)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_0_2 = blocks.file_sink(gr.sizeof_char*1, '/home/andre/ELI/'+num+'/EVE_54_8000.txt', False)
        self.blocks_file_sink_0_0_0_0_2.set_unbuffered(True)
        self.blocks_char_to_float_0_2_0_0_0 = blocks.char_to_float(1, 1)



        ##################################################
        # Connections
        ##################################################
        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_file_source_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0_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_repack_bits_bb_0_0_0_1_0, 0), (self.blocks_file_sink_0_0_0_0_2, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0_1_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.puncture64_cpp_depuncture64_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.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.puncture64_cpp_depuncture64_0, 0), (self.blocks_keep_m_in_n_0_0_2_0_0, 0))
        self.connect((self.scrambler_cpp_additive_descrambler_0, 0), (self.blocks_repack_bits_bb_0_0_0_1_0, 0))
    def __init__(self):
        gr.top_block.__init__(self)

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4000000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(1090000000, 0)
        self.uhd_usrp_sink_0.set_gain(33, 0)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, "packet_len", 2)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002",
                                                     10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1.25)
        self.AdsbEncoder_0 = adsbtx.AdsbEncoder(200)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_repeat_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.AdsbEncoder_0, "pdus",
                         self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.AdsbEncoder_0,
                         "pdus")
Example #25
0
    def __init__(self, syncword_threshold = None, options = None):
        gr.hier_block2.__init__(self, "eirsat_concatenated_deframer",
            gr.io_signature(1, 1, gr.sizeof_float),
            gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')

        self.delay1 =  blocks.delay(gr.sizeof_float, 1)
        self.viterbi0 = cmc_viterbi()
        self.viterbi1 = cmc_viterbi()
        self.char2float0 = blocks.char_to_float(1, 1)
        self.char2float1 = blocks.char_to_float(1, 1)
        self.addconst0 = blocks.add_const_ff(-0.5)
        self.addconst1 = blocks.add_const_ff(-0.5)
        self.rs0 = eirsat_deframer(syncword_threshold, options)
        self.rs1 = eirsat_deframer(syncword_threshold, options)

        self.connect(self, self.viterbi0, self.char2float0, self.addconst0, self.rs0)
        self.connect(self, self.delay1, self.viterbi1, self.char2float1, self.addconst1, self.rs1)
        self.msg_connect((self.rs0, 'out'), (self, 'out'))
        self.msg_connect((self.rs1, 'out'), (self, 'out'))
Example #26
0
 def handle_8PSK(self):
     self.statusLabel.setText("Status: Generating 8PSK Data")
     SNRval = self.SNRSlider.value()
     if (SNRval % 2 != 0):
         SNRval = (SNRval + 1) % 20
     src = gen_8psk(SNRval)
     self.lock()
     self.disconnect(self.qtgui_freq_sink_x_0)
     convert = blocks.char_to_float()
     convert2 = blocks.float_to_complex()
     self.connect((src, 0), (convert, 0), (convert2, 0),
                  (self.qtgui_freq_sink_x_0, 0))
     self.unlock()
Example #27
0
 def xtest_ccsds_27 (self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6)
     src = blocks.vector_source_b(src_data)
     enc = fec.encode_ccsds_27_bb()
     b2f = blocks.char_to_float()
     add = blocks.add_const_ff(-0.5)
     mul = blocks.multiply_const_ff(2.0)
     dec = fec.decode_ccsds_27_fb()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, enc, b2f, add, mul, dec, dst)
     self.tb.run()
     dst_data = dst.data()
     self.assertEqual(expected, dst_data)
 def xtest_ccsds_27(self):
     src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
     expected = (0, 0, 0, 0, 1, 2, 3, 4, 5, 6)
     src = blocks.vector_source_b(src_data)
     enc = fec.encode_ccsds_27_bb()
     b2f = blocks.char_to_float()
     add = blocks.add_const_ff(-0.5)
     mul = blocks.multiply_const_ff(2.0)
     dec = fec.decode_ccsds_27_fb()
     dst = blocks.vector_sink_b()
     self.tb.connect(src, enc, b2f, add, mul, dec, dst)
     self.tb.run()
     dst_data = dst.data()
     self.assertEqual(expected, dst_data)
Example #29
0
    def __init__(self,
                 frame_size=223,
                 precoding=None,
                 rs_en=True,
                 rs_basis='dual',
                 rs_interleaving=1,
                 scrambler='CCSDS',
                 convolutional='CCSDS',
                 syncword_threshold=None,
                 options=None):
        gr.hier_block2.__init__(self, 'ccsds_concatenated_deframer',
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')

        self.delay1 = blocks.delay(gr.sizeof_float, 1)
        self.viterbi0 = ccsds_viterbi(convolutional)
        self.viterbi1 = ccsds_viterbi(convolutional)
        self.char2float0 = blocks.char_to_float(1, 1)
        self.char2float1 = blocks.char_to_float(1, 1)
        self.addconst0 = blocks.add_const_ff(-0.5)
        self.addconst1 = blocks.add_const_ff(-0.5)
        self.rs0 = ccsds_rs_deframer(frame_size, precoding, rs_en, rs_basis,
                                     rs_interleaving, scrambler,
                                     syncword_threshold, options)
        self.rs1 = ccsds_rs_deframer(frame_size, precoding, rs_en, rs_basis,
                                     rs_interleaving, scrambler,
                                     syncword_threshold, options)

        self.connect(self, self.viterbi0, self.char2float0, self.addconst0,
                     self.rs0)
        self.connect(self, self.delay1, self.viterbi1, self.char2float1,
                     self.addconst1, self.rs1)
        self.msg_connect((self.rs0, 'out'), (self, 'out'))
        self.msg_connect((self.rs1, 'out'), (self, 'out'))
Example #30
0
    def __init__(self, generic_encoder=0, generic_decoder=0, esno=0,
                 samp_rate=3200000, threading="capillary", puncpat='11',
                 seed=0):
        gr.hier_block2.__init__(self, "fec_test",
                                gr.io_signature(1, 1, gr.sizeof_char*1),
                                gr.io_signature(2, 2, gr.sizeof_char*1))

        self.generic_encoder = generic_encoder
        self.generic_decoder = generic_decoder
        self.esno = esno
        self.samp_rate = samp_rate
        self.threading = threading
        self.puncpat = puncpat

        self.map_bb = digital.map_bb(([-1, 1]))
        self.b2f = blocks.char_to_float(1, 1)

        self.unpack8 = blocks.unpack_k_bits_bb(8)
        self.pack8 = blocks.pack_k_bits_bb(8)

        self.encoder = extended_encoder(encoder_obj_list=generic_encoder,
                                        threading=threading,
                                        puncpat=puncpat)

        self.decoder = extended_decoder(decoder_obj_list=generic_decoder,
                                        threading=threading,
                                        ann=None, puncpat=puncpat,
                                        integration_period=10000, rotator=None)

        noise = math.sqrt((10.0**(-esno/10.0))/2.0)
        #self.fastnoise = analog.fastnoise_source_f(analog.GR_GAUSSIAN, noise, seed, 8192)
        self.fastnoise = analog.noise_source_f(analog.GR_GAUSSIAN, noise, seed)
        self.addnoise = blocks.add_ff(1)

        # Send packed input directly to the second output
        self.copy_packed = blocks.copy(gr.sizeof_char)
        self.connect(self, self.copy_packed)
        self.connect(self.copy_packed, (self, 1))

        # Unpack inputl encode, convert to +/-1, add noise, decode, repack
        self.connect(self, self.unpack8)
        self.connect(self.unpack8, self.encoder)
        self.connect(self.encoder, self.map_bb)
        self.connect(self.map_bb, self.b2f)
        self.connect(self.b2f, (self.addnoise, 0))
        self.connect(self.fastnoise, (self.addnoise,1))
        self.connect(self.addnoise, self.decoder)
        self.connect(self.decoder, self.pack8)
        self.connect(self.pack8, (self, 0))
Example #31
0
    def __init__(self, capcode, message):
        gr.top_block.__init__(self, "Pocsagtx")

        ##################################################
        # Variables
        ##################################################
        self.symrate = symrate = 38400
        self.samp_rate = samp_rate = 5000000
        ### Set the frequency!
        #self.pagerfreq = pagerfreq = 421000000
        raise Exception("Make sure you're legal!")

        ### Set to 2500.0 for narrowband
        self.max_deviation = max_deviation = 4500.0

        ##################################################
        # Blocks
        ##################################################
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  float(samp_rate)/float(symrate),
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1))
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(pagerfreq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(10, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.mixalot_pocencode_0 = mixalot.pocencode(1, 512, capcode, message, symrate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))    
        self.connect((self.mixalot_pocencode_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))    
Example #32
0
    def test_001_t(self):
        """Encoder to Decoder - noiseless - no constellation de-mapper"""

        # Parameters
        N = 18444
        K = 6144
        pct_en = False
        n_ite = 6
        const = [1 - 1]
        flip_llrs = False

        # Input data
        in_vec = [i % 2 for i in range(K)]

        # Flowgraph
        src = blocks.vector_source_b(in_vec)
        enc = blocksattx.turbo_encoder(K, pct_en)
        mapb = digital.map_bb([1, -1])
        c2f = blocks.char_to_float()
        dec = blocksat.turbo_decoder(K, pct_en, n_ite, flip_llrs)
        snk = blocks.vector_sink_b()
        snk_sym = blocks.vector_sink_f()
        snk_llr = blocks.vector_sink_f()
        self.tb.connect(src, enc, mapb, c2f, dec, snk)
        self.tb.connect(c2f, snk_sym)
        self.tb.connect(c2f, snk_llr)
        self.tb.run()

        # NOTE: the above mapping maps bit "0" to symbol +1 and bit "1" to
        # symbol -1. The LLR is obtained directly by converting the symbol to a
        # float, meaning the assumption is that a positive LLR implies bit 0 and
        # negative LLR implies bit 1. This assumption matches with the
        # convention that is adopted in the Turbo Decoder.

        # Collect results
        out_vec = snk.data()
        syms = snk_sym.data()
        llrs = snk_llr.data()
        diff = array(in_vec) - array(out_vec)
        err = [0 if i == 0 else 1 for i in diff]

        self.dump(const, in_vec, syms, llrs, out_vec)
        print('Number of errors: %d' % (sum(err)))

        # Check results
        self.assertEqual(sum(err), 0)
Example #33
0
    def __init__(self, parameter_0=0):
        gr.top_block.__init__(self, "gfsk_tx")

        ##################################################
        # Parameters
        ##################################################
        self.parameter_0 = parameter_0

        ##################################################
        # Variables
        ##################################################
        self.transmission_rate = transmission_rate = 200e3
        self.samp_rate = samp_rate = 4e6

        ##################################################
        # Blocks
        ##################################################
        self.vlc_vlc_packet_source_b_0 = vlc.vlc_packet_source_b(
            'vlc_gr_server')
        self.vlc_vlc_board_interface_b_0 = vlc.vlc_board_interface_b(
            '192.168.1.24', 7777, 6666, 256)
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_repeat_0 = blocks.repeat(
            gr.sizeof_float * 1, int(samp_rate / transmission_rate * 32))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(255)
        self.blocks_float_to_uchar_0 = blocks.float_to_uchar()
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.vlc_vlc_board_interface_b_0, 'vlc_board_int_msg_out'),
            (self.vlc_vlc_packet_source_b_0, 'vlc_pkt_src_msg_in'))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_float_to_uchar_0, 0),
                     (self.vlc_vlc_board_interface_b_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.blocks_repeat_0, 0),
                     (self.blocks_float_to_uchar_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.vlc_vlc_packet_source_b_0, 0),
                     (self.blocks_unpack_k_bits_bb_0, 0))
Example #34
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32e3

        ##################################################
        # Blocks
        ##################################################
        self.wxgui_scopesink2_0 = 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_0.win)
        self.digital_map_bb_0 = digital.map_bb(([1, -1]))
        self.blocks_vector_source_x_0 = blocks.vector_source_i((1, 1, 1, 0), True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_int*1, samp_rate,True)
        self.blocks_int_to_float_0 = blocks.int_to_float(1, 1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_ctrlport_monitor_performance_0 = not True or monitor("gr-perf-monitorx")
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_add_xx_0, 1))    
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_char_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.blocks_float_to_char_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.blocks_int_to_float_0, 0), (self.blocks_add_xx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_int_to_float_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0, 0))    
Example #35
0
  def sim ( self, arity, snr_db, N ):
    
    vlen = 1
    N = int( N )
    snr = 10.0**(snr_db/10.0)
    
    sigpow = 1.0
    noise_pow = sigpow / snr
    
    demapper = ofdm.generic_demapper_vcb( vlen )
    const = demapper.get_constellation( arity )
    assert( len( const ) == 2**arity )
    
    symsrc = ofdm.symbol_random_src( const, vlen )
    noise_src = ofdm.complex_white_noise( 0.0, sqrt( noise_pow ) )
    channel = blocks.add_cc()
    bitmap_src = blocks.vector_source_b( [arity] * vlen, True, vlen )
    bm_trig_src = blocks.vector_source_b( [1], True )
    ref_bitstream = blocks.unpack_k_bits_bb( arity )
    bitstream_xor = blocks.xor_bb()
    bitstream_c2f = blocks.char_to_float()
    acc_biterr = ofdm.accumulator_ff()
    skiphead = blocks.skiphead( gr.sizeof_float, N-1 )
    limit = blocks.head( gr.sizeof_float, 1 )
    dst = blocks.vector_sink_f()
    
    tb = gr.top_block ( "test_block" )
    
    tb.connect( (symsrc,0), (channel,0) )
    tb.connect( noise_src,  (channel,1) )
    tb.connect( channel,     (demapper,0), (bitstream_xor,0) )
    tb.connect( bitmap_src,  (demapper,1) )
    tb.connect( bm_trig_src, (demapper,2) )
    tb.connect( (symsrc,1), ref_bitstream, (bitstream_xor,1) )
    tb.connect( bitstream_xor, bitstream_c2f, acc_biterr )
    tb.connect( acc_biterr, skiphead, limit, dst )

    tb.run()
    
    bit_errors = numpy.array( dst.data() )
    assert( len( bit_errors ) == 1 )
    bit_errors = bit_errors[0]
    
    return bit_errors / N
    def __init__(self, inmessage, incapcode):
        gr.top_block.__init__(self, "Pocsagtx Hackrf")

        ##################################################
        # Variables
        ##################################################
        self.symrate = symrate = 38400
        self.samp_rate = samp_rate = 8000000
        self.pagerfreq = pagerfreq = 920612500
        self.max_deviation = max_deviation = 4500.0

        ##################################################
        # Blocks
        ##################################################
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  float(samp_rate)/float(symrate),
                  taps=None,
        	  flt_size=16)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)
        	
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "hackrf=0" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(pagerfreq, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(15, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)
          
        self.mixalot_pocencode_0 = mixalot.pocencode(1, 512, incapcode, inmessage, symrate)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, ))
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2.0 * math.pi * max_deviation / float(symrate))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.mixalot_pocencode_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
Example #37
0
    def test_002_t(self):
        """
        test 384 bit packet with interleaver
        """
        # set up fg
        data_in = np.random.randint(0, 2, size=384)
        key = pmt.intern("len_tag")
        val = pmt.from_long(384)
        tag = gr.tag_utils.python_to_tag((0, key, val))
        self.src = blocks.vector_source_b(data_in, False, 1, [tag])
        self.intlvr = lpwan.dsss_interleaver_bb("len_tag")
        self.cast = blocks.char_to_float()
        self.deintlvr = lpwan.dsss_deinterleaver_ff("len_tag")
        self.snk = blocks.vector_sink_f(1)
        self.tb.connect(self.src, self.intlvr, self.cast, self.deintlvr,
                        self.snk)
        self.tb.run()

        # check data
        self.assertFloatTuplesAlmostEqual(data_in, self.snk.data())
Example #38
0
    def __init__(self,delay=0,amplitude=1):
        """Simple Modulation Block Fixture
        
        Keyword Arguments:
            delay {int} -- Delay to introduce (default: {0})
            amplitude {int} -- Amplitude Change (default: {1})
        """ 
        valid_mod_block.__init__(self)

        # Blocks
        self.b_to_f = blocks.char_to_float(1, 1)
        self.symbol_map_mult = blocks.multiply_const_vff((2.0, ))
        self.symbol_map_subtract = blocks.add_const_vff((-1.0,))
        self.delay_f = blocks.delay(gr.sizeof_float,delay=delay)
        self.f_to_c = blocks.float_to_complex(1)
        self.mult_f = blocks.multiply_const_vff((amplitude, ))
        
        self.c_to_r = blocks.complex_to_real(1)
        self.divide_f = blocks.multiply_const_vff((1.0/amplitude, ))
        self.symbol_map_add = blocks.add_const_vff((1.0,))
        self.symbol_map_divide = blocks.multiply_const_vff((1/2.0,))
        self.f_to_b = blocks.float_to_char(1,1)
        
        # Connections
        self.connect((self,0),self.b_to_f)
        self.connect(self.b_to_f,self.symbol_map_mult)
        self.connect(self.symbol_map_mult,self.symbol_map_subtract)
        self.connect(self.symbol_map_subtract,self.mult_f)
        self.connect(self.mult_f,(self,2))
        self.connect(self.mult_f,self.delay_f)
        self.connect(self.delay_f,self.f_to_c)
        self.connect(self.f_to_c,(self,1))

        self.connect((self,1),self.c_to_r)
        self.connect(self.c_to_r,self.divide_f)
        self.connect(self.divide_f,self.symbol_map_add)
        self.connect(self.symbol_map_add,self.symbol_map_divide)
        self.connect(self.symbol_map_divide,(self,3))
        self.connect(self.symbol_map_divide,self.f_to_b)        
        self.connect(self.f_to_b,(self,0))
Example #39
0
    def __init__(self, input_rate, baud):
        gr.hier_block2.__init__(
            self,
            'RTTY FSK demodulator',
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_float * 1),
        )

        self.bit_time = bit_time = input_rate / baud

        fsk_deviation_hz = 85  # TODO param or just don't care

        self.__dc_blocker = grfilter.dc_blocker_ff(
            int(bit_time * _HALF_BITS_PER_CODE * 10), False)
        self.__quadrature_demod = analog.quadrature_demod_cf(
            -input_rate / (2 * math.pi * fsk_deviation_hz))
        self.__freq_probe = blocks.probe_signal_f()

        self.connect(self, self.__quadrature_demod, self.__dc_blocker,
                     digital.binary_slicer_fb(), blocks.char_to_float(scale=1),
                     self)
        self.connect(self.__dc_blocker, self.__freq_probe)
Example #40
0
 def __init__(self, input_rate, baud):
     gr.hier_block2.__init__(
         self, 'RTTY FSK demodulator',
         gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
         gr.io_signature(1, 1, gr.sizeof_float * 1),
     )
     
     self.bit_time = bit_time = input_rate / baud
     
     fsk_deviation_hz = 85  # TODO param or just don't care
     
     self.__dc_blocker = grfilter.dc_blocker_ff(int(bit_time * _HALF_BITS_PER_CODE * 10), False)
     self.__quadrature_demod = analog.quadrature_demod_cf(-input_rate / (2 * math.pi * fsk_deviation_hz))
     self.__freq_probe = blocks.probe_signal_f()
     
     self.connect(
         self,
         self.__quadrature_demod,
         self.__dc_blocker,
         digital.binary_slicer_fb(),
         blocks.char_to_float(scale=1),
         self)
     self.connect(self.__dc_blocker, self.__freq_probe)
Example #41
0
    def __init__(self, samp_per_bit, samp_rate, spacing, taps=None):
        gr.hier_block2.__init__(
            self,
            "FM FSK Modulator",
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )

        ##################################################
        # Parameters
        ##################################################
        self.samp_per_bit = samp_per_bit
        self.samp_rate = samp_rate
        self.spacing = spacing
        self.taps = taps

        ##################################################
        # Blocks
        ##################################################
        self._repeat = blocks.repeat(gr.sizeof_char, samp_per_bit)
        self._char_to_float = blocks.char_to_float(1, 1)
        self._add = blocks.add_const_vff((-1.0, ))
        self._filter = interp_fir_filter_fff(1, self._taps())
        self._fm_mod = frequency_modulator_fc(self._fm_mod_sensitivity())

        ##################################################
        # Connections
        ##################################################
        self.connect(
            self,
            self._repeat,
            self._char_to_float,
            self._add,
            self._filter,
            self._fm_mod,
            self,
        )
Example #42
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))
Example #43
0
    def __init__(self, fft_length, cp_length, snr, kstime, logging):
        ''' Maximum Likelihood OFDM synchronizer:
        J. van de Beek, M. Sandell, and P. O. Borjesson, "ML Estimation
        of Time and Frequency Offset in OFDM Systems," IEEE Trans.
        Signal Processing, vol. 45, no. 7, pp. 1800-1805, 1997.
        '''

        gr.hier_block2.__init__(self, "ofdm_sync_ml",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
                                gr.io_signature2(2, 2, gr.sizeof_float, gr.sizeof_char)) # Output signature

        self.input = blocks.add_const_cc(0)

        SNR = 10.0**(snr / 10.0)
        rho = SNR / (SNR + 1.0)
        symbol_length = fft_length + cp_length

        # ML Sync

        # Energy Detection from ML Sync

        self.connect(self, self.input)

        # Create a delay line
        self.delay = blocks.delay(gr.sizeof_gr_complex, fft_length)
        self.connect(self.input, self.delay)

        # magnitude squared blocks
        self.magsqrd1 = blocks.complex_to_mag_squared()
        self.magsqrd2 = blocks.complex_to_mag_squared()
        self.adder = blocks.add_ff()

        moving_sum_taps = [rho / 2 for i in range(cp_length)]
        self.moving_sum_filter = filter.fir_filter_fff(1,moving_sum_taps)

        self.connect(self.input,self.magsqrd1)
        self.connect(self.delay,self.magsqrd2)
        self.connect(self.magsqrd1,(self.adder,0))
        self.connect(self.magsqrd2,(self.adder,1))
        self.connect(self.adder,self.moving_sum_filter)


        # Correlation from ML Sync
        self.conjg = blocks.conjugate_cc();
        self.mixer = blocks.multiply_cc();

        movingsum2_taps = [1.0 for i in range(cp_length)]
        self.movingsum2 = filter.fir_filter_ccf(1,movingsum2_taps)

        # Correlator data handler
        self.c2mag = blocks.complex_to_mag()
        self.angle = blocks.complex_to_arg()
        self.connect(self.input,(self.mixer,1))
        self.connect(self.delay,self.conjg,(self.mixer,0))
        self.connect(self.mixer,self.movingsum2,self.c2mag)
        self.connect(self.movingsum2,self.angle)

        # ML Sync output arg, need to find maximum point of this
        self.diff = blocks.sub_ff()
        self.connect(self.c2mag,(self.diff,0))
        self.connect(self.moving_sum_filter,(self.diff,1))

        #ML measurements input to sampler block and detect
        self.f2c = blocks.float_to_complex()
        self.pk_detect = blocks.peak_detector_fb(0.2, 0.25, 30, 0.0005)
        self.sample_and_hold = blocks.sample_and_hold_ff()

        # use the sync loop values to set the sampler and the NCO
        #     self.diff = theta
        #     self.angle = epsilon

        self.connect(self.diff, self.pk_detect)

        # The DPLL corrects for timing differences between CP correlations
        use_dpll = 0
        if use_dpll:
            self.dpll = gr.dpll_bb(float(symbol_length),0.01)
            self.connect(self.pk_detect, self.dpll)
            self.connect(self.dpll, (self.sample_and_hold,1))
        else:
            self.connect(self.pk_detect, (self.sample_and_hold,1))

        self.connect(self.angle, (self.sample_and_hold,0))

        ################################
        # correlate against known symbol
        # This gives us the same timing signal as the PN sync block only on the preamble
        # we don't use the signal generated from the CP correlation because we don't want
        # to readjust the timing in the middle of the packet or we ruin the equalizer settings.
        kstime = [k.conjugate() for k in kstime]
        kstime.reverse()
        self.kscorr = filter.fir_filter_ccc(1, kstime)
        self.corrmag = blocks.complex_to_mag_squared()
        self.div = blocks.divide_ff()

        # The output signature of the correlation has a few spikes because the rest of the
        # system uses the repeated preamble symbol. It needs to work that generically if
        # anyone wants to use this against a WiMAX-like signal since it, too, repeats.
        # The output theta of the correlator above is multiplied with this correlation to
        # identify the proper peak and remove other products in this cross-correlation
        self.threshold_factor = 0.1
        self.slice = blocks.threshold_ff(self.threshold_factor, self.threshold_factor, 0)
        self.f2b = blocks.float_to_char()
        self.b2f = blocks.char_to_float()
        self.mul = blocks.multiply_ff()

        # Normalize the power of the corr output by the energy. This is not really needed
        # and could be removed for performance, but it makes for a cleaner signal.
        # if this is removed, the threshold value needs adjustment.
        self.connect(self.input, self.kscorr, self.corrmag, (self.div,0))
        self.connect(self.moving_sum_filter, (self.div,1))

        self.connect(self.div, (self.mul,0))
        self.connect(self.pk_detect, self.b2f, (self.mul,1))
        self.connect(self.mul, self.slice)

        # Set output signals
        #    Output 0: fine frequency correction value
        #    Output 1: timing signal
        self.connect(self.sample_and_hold, (self,0))
        self.connect(self.slice, self.f2b, (self,1))


        if logging:
            self.connect(self.moving_sum_filter, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-energy_f.dat"))
            self.connect(self.diff, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-theta_f.dat"))
            self.connect(self.angle, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-epsilon_f.dat"))
            self.connect(self.corrmag, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-corrmag_f.dat"))
            self.connect(self.kscorr, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-kscorr_c.dat"))
            self.connect(self.div, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-div_f.dat"))
            self.connect(self.mul, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-mul_f.dat"))
            self.connect(self.slice, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-slice_f.dat"))
            self.connect(self.pk_detect, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-peaks_b.dat"))
            if use_dpll:
                self.connect(self.dpll, blocks.file_sink(gr.sizeof_char, "ofdm_sync_ml-dpll_b.dat"))

            self.connect(self.sample_and_hold, blocks.file_sink(gr.sizeof_float, "ofdm_sync_ml-sample_and_hold_f.dat"))
            self.connect(self.input, blocks.file_sink(gr.sizeof_gr_complex, "ofdm_sync_ml-input_c.dat"))
Example #44
0
    def __init__(self, rxPort=52002, txPort=52001):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.rxPort = rxPort
        self.txPort = txPort

        ##################################################
        # Variables
        ##################################################
        self.localOscillator = localOscillator = 14070000
        self.threshold = threshold = -200
        self.samp_rate = samp_rate = 48000
        self.rxPhase = rxPhase = .84
        self.rxMagnitude = rxMagnitude = 0.854
        self.freqFine = freqFine = 0
        self.freq = freq = localOscillator
        self.bandwidth = bandwidth = 50

        ##################################################
        # Blocks
        ##################################################
        _threshold_sizer = wx.BoxSizer(wx.VERTICAL)
        self._threshold_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	label="threshold",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._threshold_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_threshold_sizer,
        	value=self.threshold,
        	callback=self.set_threshold,
        	minimum=-500,
        	maximum=500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_threshold_sizer)
        self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning")
        self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope")
        self.Add(self.notebook_0)
        _freqFine_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freqFine_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freqFine_sizer,
        	value=self.freqFine,
        	callback=self.set_freqFine,
        	label="Tuning",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freqFine_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freqFine_sizer,
        	value=self.freqFine,
        	callback=self.set_freqFine,
        	minimum=-500,
        	maximum=500,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freqFine_sizer)
        _freq_sizer = wx.BoxSizer(wx.VERTICAL)
        self._freq_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	label="Frequency",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._freq_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_freq_sizer,
        	value=self.freq,
        	callback=self.set_freq,
        	minimum=localOscillator-samp_rate,
        	maximum=localOscillator+samp_rate,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_freq_sizer)
        _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL)
        self._bandwidth_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_bandwidth_sizer,
        	value=self.bandwidth,
        	callback=self.set_bandwidth,
        	label="Signal Bandwidth",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._bandwidth_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_bandwidth_sizer,
        	value=self.bandwidth,
        	callback=self.set_bandwidth,
        	minimum=30,
        	maximum=5000,
        	num_steps=1000,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_bandwidth_sizer)
        self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(1).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=125*8,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win)
        self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=125*8,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win)
        self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	self.notebook_0.GetPage(0).GetWin(),
        	baseband_freq=localOscillator,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass(
        	1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass(
        	1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76))
        self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001)
        self.blocks_transcendental_1 = blocks.transcendental("sin", "float")
        self.blocks_transcendental_0 = blocks.transcendental("cos", "float")
        self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25)
        self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25))
        self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1)
        self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_float_to_char_0 = blocks.float_to_char(1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.blks2_tcp_source_0 = grc_blks2.tcp_source(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=txPort,
        	server=False,
        )
        self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
        	itemsize=gr.sizeof_char*1,
        	addr="127.0.0.1",
        	port=rxPort,
        	server=False,
        )
        self.audio_source_0 = audio.source(samp_rate, "", True)
        self.audio_sink_0 = audio.sink(samp_rate, "", True)
        self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0)
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0))
        self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0))
        self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1))
        self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0))
        self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0))
        self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1))
        self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0))
        self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0))
        self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0))
        self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0))
        self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1))
        self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1))
        self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0))
        self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1))
        self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0))
        self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
Example #45
0
File: chu.py Project: argilo/gr-ham
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Chu")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1200000
        self.upconverter_lo_freq = upconverter_lo_freq = 125000000
        self.space_tone = space_tone = 2025
        self.offset = offset = 100000
        self.mark_tone = mark_tone = 2225
        self.gain = gain = 10
        self.decimation = decimation = samp_rate / 48000
        self.chu_freq = chu_freq = 3330000
        self.channel_rate = channel_rate = 4800

        ##################################################
        # Blocks
        ##################################################
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope")
        self.GridAdd(self.nb, 2, 0, 1, 1)
        _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="USB tuner 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=50,
        	num_steps=125,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.GridAdd(_gain_sizer, 1, 0, 1, 1)
        self._chu_freq_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.chu_freq,
        	callback=self.set_chu_freq,
        	label="CHU frequency",
        	choices=[3330000, 7850000, 14670000],
        	labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1)
        self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c(
        	self.nb.GetPage(1).GetWin(),
        	baseband_freq=(mark_tone + space_tone) / 2,
        	dynamic_range=50,
        	ref_level=-20,
        	ref_scale=2.0,
        	sample_rate=channel_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        )
        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=chu_freq,
        	dynamic_range=50,
        	ref_level=-60,
        	ref_scale=2.0,
        	sample_rate=samp_rate / decimation,
        	fft_size=2048,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot",
        	win=window.hamming,
        )
        self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
        	self.nb.GetPage(2).GetWin(),
        	title="Scope Plot",
        	sample_rate=channel_rate,
        	v_scale=1,
        	v_offset=0,
        	t_scale=0.050,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=2,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_fff(1, firdes.root_raised_cosine(
        	1, channel_rate, 300, 0.35, 100))
        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(chu_freq - offset + upconverter_lo_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 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.low_pass_filter_1 = filter.fir_filter_ccf(10, firdes.low_pass(
        	1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass(
        	1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76))
        self.ham_chu_decode_0 = ham.chu_decode()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_multiply_xx_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass(
        	1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76))
        self.audio_sink_0_0 = audio.sink(48000, "", True)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(channel_rate / (3.1416*(mark_tone - space_tone)))
        self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(3.1416 / 500, 1.8, -1.8)
        self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0))
        self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0))
        self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0))
        self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
Example #46
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))    
    def __init__(self, frame_size=100, puncpat='11'):
        gr.top_block.__init__(self, "Fecapi Ldpc Decoders")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fecapi Ldpc Decoders")
        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", "fecapi_ldpc_decoders")
        self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray))


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

        ##################################################
        # Variables
        ##################################################
        self.H = H = fec.ldpc_H_matrix(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0042_gap_02.alist", 2)
        self.G = G = fec.ldpc_G_matrix(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0058_gen_matrix.alist")
        self.samp_rate = samp_rate = 50000


        self.ldpc_enc_H = ldpc_enc_H = fec.ldpc_par_mtrx_encoder_make_H(H)


        self.ldpc_enc_G = ldpc_enc_G = fec.ldpc_gen_mtrx_encoder_make(G)


        self.ldpc_enc = ldpc_enc = fec.ldpc_encoder_make(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0042_gap_02.alist");


        self.ldpc_dec_H = ldpc_dec_H = fec.ldpc_bit_flip_decoder.make(H.get_base_sptr(), 100)


        self.ldpc_dec_G = ldpc_dec_G = fec.ldpc_bit_flip_decoder.make(G.get_base_sptr(), 100)


        self.ldpc_dec = ldpc_dec = fec.ldpc_decoder.make(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0042_gap_02.alist", 0.5, 50);

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #size
        	samp_rate, #samp_rate
        	'', #name
        	4 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0.set_y_axis(-0.5, 1.5)

        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 = ['Input', 'LDPC (alist)', 'LDPC (H)', 'LDPC (G)', 'CCSDS',
                  '', '', '', '', '']
        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, 0.6, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fec_extended_encoder_1_0_0 = fec.extended_encoder(encoder_obj_list=ldpc_enc, threading= None, puncpat=puncpat)
        self.fec_extended_encoder_1_0 = fec.extended_encoder(encoder_obj_list=ldpc_enc_H, threading= None, puncpat=puncpat)
        self.fec_extended_encoder_1 = fec.extended_encoder(encoder_obj_list=ldpc_enc_G, threading= None, puncpat=puncpat)
        self.fec_extended_decoder_0_1_0 = fec.extended_decoder(decoder_obj_list=ldpc_dec, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.fec_extended_decoder_0_1 = fec.extended_decoder(decoder_obj_list=ldpc_dec_H, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=ldpc_dec_G, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_map_bb_0_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_map_bb_0_0_0 = digital.map_bb(([-1, 1]))
        self.digital_map_bb_0_0 = digital.map_bb(([-1, 1]))
        self.blocks_vector_source_x_0_1_0 = blocks.vector_source_b((frame_size/15)*[0, 0, 1, 0, 3, 0, 7, 0, 15, 0, 31, 0, 63, 0, 127], True, 1, [])
        self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_char_to_float_0_2_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_2 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0_0_0_0 = blocks.char_to_float(1, 1)
        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_char_to_float_0, 0), (self.fec_extended_decoder_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 3))
        self.connect((self.blocks_char_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_char_to_float_0_0_0_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_2, 0), (self.fec_extended_decoder_0_1, 0))
        self.connect((self.blocks_char_to_float_0_2_0, 0), (self.fec_extended_decoder_0_1_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_unpack_k_bits_bb_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_extended_encoder_1, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_extended_encoder_1_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.fec_extended_encoder_1_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_1_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_map_bb_0_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_map_bb_0_0_0, 0), (self.blocks_char_to_float_0_2, 0))
        self.connect((self.digital_map_bb_0_0_0_0, 0), (self.blocks_char_to_float_0_2_0, 0))
        self.connect((self.fec_extended_decoder_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.fec_extended_decoder_0_1, 0), (self.blocks_char_to_float_0_0_0, 0))
        self.connect((self.fec_extended_decoder_0_1_0, 0), (self.blocks_char_to_float_0_0_0_0, 0))
        self.connect((self.fec_extended_encoder_1, 0), (self.digital_map_bb_0_0, 0))
        self.connect((self.fec_extended_encoder_1_0, 0), (self.digital_map_bb_0_0_0, 0))
        self.connect((self.fec_extended_encoder_1_0_0, 0), (self.digital_map_bb_0_0_0_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.interleave = interleave = 4

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	800, #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(-130, 130)
        
        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 = ["", "", "", "", "",
                  "", "", "", "", ""]
        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.ccsds_rs_decode_pdu_0 = ccsds.rs_decode_pdu(interleave)
        self.ccsds_asm_deframer_pdu_0 = ccsds.asm_deframer_pdu(0, interleave, 1, 255)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test_Files/BAL_FEC_Test/frame.bit", False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test_Files/BAL_FEC_Test/frame_out.bit", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.blocks_char_to_float_1 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_asm_deframer_pdu_0, 'pdus'), (self.ccsds_rs_decode_pdu_0, 'pdu_in'))    
        self.msg_connect((self.ccsds_rs_decode_pdu_0, 'pdu_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.connect((self.blocks_char_to_float_1, 0), (self.qtgui_time_sink_x_1, 0))    
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.ccsds_asm_deframer_pdu_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_1, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0))    
Example #49
0
    def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'):
        grc_wxgui.top_block_gui.__init__(self, title="Uplink")

        ##################################################
        # Parameters
        ##################################################
        self.sym_rate = sym_rate
        self.samp_per_sym = samp_per_sym
        self.nominal_uplink_freq = nominal_uplink_freq
        self.lo_off = lo_off
        self.tx_gain = tx_gain
        self.backoff = backoff
        self.record_path = record_path

        ##################################################
        # Variables
        ##################################################
        self.time_format = time_format = "%Y-%d-%m_%H-%M-%S"
        self.time_now = time_now = time.strftime(time_format)
        self.samp_rate = samp_rate = 250000
        self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym
        self.f1 = f1 = 9000.0
        self.f0 = f0 = 7500.0
        self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate)
        self.pm = pm = 1.2*0 + 1.0
        self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq
        self.manual_doppler = manual_doppler = 0
        self.file_name = file_name = time_now + ".mcfile"
        self.doppler = doppler = 0
        self.deviation = deviation = (f1 - f0) / 2.0
        self.tx_gain_user = tx_gain_user = tx_gain
        self.subcarrier_freq = subcarrier_freq = f0 + deviation
        self.source = source = 'external'
        self.pm_txt = pm_txt = pm
        self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser
        self.lo_off_user = lo_off_user = lo_off
        self.length_mul = length_mul = float(samp_per_sym) * resamp_rate
        self.invert = invert = 1
        self.final_record_path = final_record_path = os.path.join(record_path, file_name)
        self.final_doppler = final_doppler = doppler + manual_doppler
        self.backoff_user = backoff_user = backoff

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_user_sizer,
        	value=self.tx_gain_user,
        	callback=self.set_tx_gain_user,
        	label="TX Gain",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_user_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_user_sizer,
        	value=self.tx_gain_user,
        	callback=self.set_tx_gain_user,
        	minimum=0,
        	maximum=32,
        	num_steps=32,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_user_sizer)
        self._nominal_uplink_freq_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.nominal_uplink_freq_user,
        	callback=self.set_nominal_uplink_freq_user,
        	label="Nominal Uplink Freq",
        	converter=forms.float_converter(),
        )
        self.Add(self._nominal_uplink_freq_user_text_box)
        self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope")
        self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input")
        self.Add(self.nb)
        self._lo_off_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.lo_off_user,
        	callback=self.set_lo_off_user,
        	label="LO Offset",
        	converter=forms.float_converter(),
        )
        self.Add(self._lo_off_user_text_box)
        self._final_doppler_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.final_doppler,
        	callback=self.set_final_doppler,
        	label="Final Doppler",
        	converter=forms.float_converter(),
        )
        self.Add(self._final_doppler_static_text)
        self._doppler_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.doppler,
        	callback=self.set_doppler,
        	label="Doppler Shift",
        	converter=forms.float_converter(),
        )
        self.Add(self._doppler_text_box)
        _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL)
        self._backoff_user_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_backoff_user_sizer,
        	value=self.backoff_user,
        	callback=self.set_backoff_user,
        	label="Backoff",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._backoff_user_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_backoff_user_sizer,
        	value=self.backoff_user,
        	callback=self.set_backoff_user,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_backoff_user_sizer)
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        threading.Thread(target=self.xmlrpc_server_0.serve_forever).start()
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
        	self.nb.GetPage(5).GetWin(),
        	title="Scope Plot",
        	sample_rate=pre_resamp_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.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_scopesink2_1 = scopesink2.scope_sink_c(
        	self.nb.GetPage(4).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.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.nb.GetPage(0).GetWin(),
        	baseband_freq=0,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=samp_rate,
        	fft_size=256,
        	fft_rate=10,
        	average=False,
        	avg_alpha=None,
        	title="FFT Plot",
        	peak_hold=False,	fft_in=False,
        	always_run=False,
        	fft_out=False,
        )
        self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("serial=F4A7C3", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"",
        	True,
        )
        self.uhd_usrp_sink_0.set_clock_source(source, 0)
        self.uhd_usrp_sink_0.set_time_source(source, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=int(samp_rate),
                decimation=int(pre_resamp_rate),
                taps=None,
                fractional_bw=None,
        )
        self._pm_txt_static_text = forms.static_text(
        	parent=self.GetWin(),
        	value=self.pm_txt,
        	callback=self.set_pm_txt,
        	label="Phase Moduation Index",
        	converter=forms.float_converter(),
        )
        self.Add(self._pm_txt_static_text)
        self._nominal_uplink_freq_chooser_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.nominal_uplink_freq_chooser,
        	callback=self.set_nominal_uplink_freq_chooser,
        	label="Nomial Uplink Frequency",
        	choices=[2041.9479e6, 2090.66e6],
        	labels=['B: 2041.9479', 'A: 2090.66'],
        )
        self.Add(self._nominal_uplink_freq_chooser_chooser)
        self._manual_doppler_text_box = forms.text_box(
        	parent=self.GetWin(),
        	value=self.manual_doppler,
        	callback=self.set_manual_doppler,
        	label="Manual Doppler",
        	converter=forms.float_converter(),
        )
        self.Add(self._manual_doppler_text_box)
        self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False)
        self.clock_and_data = scopesink2.scope_sink_c(
        	self.nb.GetPage(3).GetWin(),
        	title="Scope Plot",
        	sample_rate=pre_resamp_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.nb.GetPage(3).Add(self.clock_and_data.win)
        self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0)
        self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) +  [0] * (samp_per_sym/4) +  [0] * (samp_per_sym/4) +  [1] * (samp_per_sym/4)), True, 1, [])
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, ))
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, ))
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0)
        self.blocks_float_to_complex_2 = blocks.float_to_complex(1)
        self.blocks_float_to_complex_1 = blocks.float_to_complex(1)
        self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True)
        self.blocks_file_meta_sink_0.set_unbuffered(False)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, ))
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, ))
        self.binary_to_pdu0 = isee3.binary_to_pdu()
        self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0)
        self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1))
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0))
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0))
        self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0))
        self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0))
        self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0))
        self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2))
        self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0))
        self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in")
        self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
Example #50
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.samp_rate = samp_rate = 48000
        
        
        self.enc_cc = enc_cc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False)
            
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)
            

        ##################################################
        # Blocks
        ##################################################
        self.splash_packet_encoder_0 = splash.packet_encoder(
                  samples_per_symbol=8,
                  bits_per_symbol=1,
                  preamble="",
                  access_code="",
                  pad_for_usrp=False,
        	  payload_length=9
                )
          
        self.splash_packet_decoder_0 = splash.packet_decoder(
                  access_code="",
                  threshold=-1
                )
          
        self.splash_XCEIVER_0 = splash.XCEIVER()
        self.digital_map_bb_0 = digital.map_bb(([-1,1]))
        self.dflood_dflood_0 = dflood.dflood(
          2, 0, 30, False, False, 
          5, 65, 2, 120, 50, 2, True, None
          )
        self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "packet_len", True, gr.GR_MSB_FIRST)
        self.blocks_random_pdu_0_0 = blocks.random_pdu(1, 5, chr(0xFF), 1)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_message_strobe_2 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.audio_source_0 = audio.source(48000, "", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(-70, 1)
        self.Async_Ecnoder = fec.async_encoder(enc_cc, True, False, False, 1500)
        self.Async_Decoder = fec.async_decoder(dec_cc, True, False, 1500)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Async_Decoder, 'out'), (self.dflood_dflood_0, 'from_radio'))    
        self.msg_connect((self.Async_Ecnoder, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0_0, 'generate'))    
        self.msg_connect((self.blocks_message_strobe_2, 'strobe'), (self.dflood_dflood_0, 'ctrl_in'))    
        self.msg_connect((self.blocks_random_pdu_0_0, 'pdus'), (self.dflood_dflood_0, 'from_app'))    
        self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'), (self.Async_Decoder, 'in'))    
        self.msg_connect((self.dflood_dflood_0, 'to_radio'), (self.Async_Ecnoder, 'in'))    
        self.msg_connect((self.dflood_dflood_0, 'to_app'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.audio_source_0, 0), (self.splash_XCEIVER_0, 0))    
        self.connect((self.blocks_char_to_float_0_1, 0), (self.blocks_tagged_stream_to_pdu_1, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.splash_packet_encoder_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0))    
        self.connect((self.splash_XCEIVER_0, 2), (self.analog_probe_avg_mag_sqrd_x_0, 0))    
        self.connect((self.splash_XCEIVER_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.splash_XCEIVER_0, 1), (self.splash_packet_decoder_0, 0))    
        self.connect((self.splash_packet_decoder_0, 0), (self.blocks_repack_bits_bb_0, 0))    
        self.connect((self.splash_packet_encoder_0, 0), (self.splash_XCEIVER_0, 1))    
Example #51
0
def char_to_float(N):
    op = blocks.char_to_float()
    tb = helper(N, op, gr.sizeof_char, gr.sizeof_float, 1, 1)
    def __init__(self):
        gr.top_block.__init__(self, "Transceiver Test for Client Node")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Transceiver Test for Client Node")
        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", "inets_transceiver_test_client")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.threshold = threshold = 50
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)

        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.qam16_mod = qam16_mod = gnuradio.digital.qam_constellation(16,False).base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "TX")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "RX")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Demod")
        self.tab_widget_3 = Qt.QWidget()
        self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3)
        self.tab_grid_layout_3 = Qt.QGridLayout()
        self.tab_layout_3.addLayout(self.tab_grid_layout_3)
        self.tab.addTab(self.tab_widget_3, "RSSI")
        self.top_layout.addWidget(self.tab)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=192.168.10.2", "")),
        	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(2e9, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        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(1.5e9, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self._range_rx_gain_range = Range(0, 60, 1, 0, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_noise_range = Range(0, 0.01, 0.00001, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, "noise", "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_f(
        	1000000, #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(-80, -40)

        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 = ["", "", "", "", "",
                  "", "", "", "", ""]
        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.tab_layout_3.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	256, #size
        	1, #samp_rate
        	"Frequency Offset", #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, 1, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)

        if not 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 = [0, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

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

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	100000, #size
        	samp_rate / 4, #samp_rate
        	"Correlation", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 200)

        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, 20, 0, 1, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

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

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

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"TX Constellation", #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(True)
        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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_0_0_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
        	1024, #size
        	"Payload", #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, "fd")
        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.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.inets_rssi_0 = inets.rssi(0.00004)
        self.inets_radio_0 = inets_radio(
            constellation=qpsk_mod,
            matched_filter_coeff=rrc,
            mu=mu,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            threshold=threshold,
        )
        self.inets_per_logger_0 = inets.per_logger()
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, 1, 0)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((10, ))
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_radio_0, 'in'))
        self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in'))
        self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in'))
        self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 2))
        self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1))
        self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0))
        self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.inets_radio_0, 5), (self.blocks_char_to_float_0, 0))
        self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0))
        self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 6), (self.qtgui_const_sink_x_0_0_0, 0))
        self.connect((self.inets_radio_0, 4), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.inets_rssi_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.inets_rssi_0, 1), (self.blocks_null_sink_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.inets_radio_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.inets_rssi_0, 0))
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 614400
        self.rf_freq = rf_freq = 145e6
        self.rf_bw = rf_bw = 100e3

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		otw_format="sc12",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(rf_freq, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.uhd_usrp_sink_0.set_bandwidth(rf_bw, 0)
        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_NORM, qtgui.TRIG_SLOPE_POS, 0.5, 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)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(2*1):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.blocks_random_pdu_0 = blocks.random_pdu(2000, 2000, chr(0xFF), 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate'))    
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1))    
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	128, #size
        	samp_rate, #samp_rate
        	"", #name
        	3 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1.5, 2.5)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(3):
            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.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        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.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-1.5, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((1.5, ))
        self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(1)
        self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 128)), False)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_random_source_x_0, 0), (self.ax25_nrzi_encoder_0, 0))    
        self.connect((self.analog_random_source_x_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_diff_decoder_bb_0, 0))    
        self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0, 2))    
        self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0))    
        self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_add_const_vxx_0_0, 0))    
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0_0_0, 0))    
    def __init__(self, frame_size=32, puncpat='11'):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Variables
        ##################################################
        self.samples_per_symbol = samples_per_symbol = 64
        self.rate = rate = 2
        self.polys = polys = [79, 109]
        self.k = k = 7
        self.bitrate = bitrate = 9600
        self.samp_rate = samp_rate = samples_per_symbol*bitrate
        self.gain = gain = 50
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False)
            
        self.centre_freq = centre_freq = 401e6
        self.bandwidth = bandwidth = 200e3

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 100, 1, 50, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(centre_freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0)
        self.show_text_0 = display.show_text()
        self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._show_text_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #size
        	bitrate, #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(-128, 128)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_time_sink_x_0.disable_legend()
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.fosphor_qt_sink_c_0 = fosphor.qt_sink_c()
        self.fosphor_qt_sink_c_0.set_fft_window(window.WIN_BLACKMAN_hARRIS)
        self.fosphor_qt_sink_c_0.set_frequency_range(0, samp_rate)
        self._fosphor_qt_sink_c_0_win = sip.wrapinstance(self.fosphor_qt_sink_c_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._fosphor_qt_sink_c_0_win)
        self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000)
        self.digital_map_bb_0 = digital.map_bb(([-1, 1]))
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
        	samples_per_symbol=samples_per_symbol,
        	gain_mu=0.175,
        	mu=0.5,
        	omega_relative_limit=0.005,
        	freq_error=0.0,
        	verbose=False,
        	log=False,
        )
        self.ccsds_asm_deframer_0 = ccsds.asm_deframer(0,1,False,16)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test Files/Simple GMSK Receive/out.bin", False)
        self.blocks_file_sink_0.set_unbuffered(False)
        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_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40, 1e-4, 0, True)
        self.ais_invert_0 = ais.invert()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.analog_pwr_squelch_xx_0, 0), (self.digital_gmsk_demod_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.fec_extended_decoder_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ccsds_asm_deframer_0, 0), (self.show_text_0, 0))    
        self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
        self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.analog_pwr_squelch_xx_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.fosphor_qt_sink_c_0, 0))    
Example #56
0
    def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192):
        grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200")

        ##################################################
        # Parameters
        ##################################################
        self.subdev = subdev
        self.devid = devid
        self.frequency = frequency
        self.fftsize = fftsize

        ##################################################
        # Variables
        ##################################################
        self.GUI_samp_rate = GUI_samp_rate = 10e6
        self.samp_rate = samp_rate = int(GUI_samp_rate)
        self.prefix = prefix = "tpr_"
        self.text_samp_rate = text_samp_rate = GUI_samp_rate
        self.text_deviceID = text_deviceID = subdev
        self.text_Device_addr = text_Device_addr = devid
        self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.spavg = spavg = 1
        self.scope_rate = scope_rate = 2
        self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat"
        self.rec_button_tpr = rec_button_tpr = 1
        self.rec_button_iq = rec_button_iq = 1
        self.noise_amplitude = noise_amplitude = .5
        self.integ = integ = 2
        self.gain = gain = 26
        self.freq = freq = frequency
        self.file_rate = file_rate = 2.0
        self.fftrate = fftrate = int(samp_rate/fftsize)
        self.det_rate = det_rate = int(20.0)
        self.dc_gain = dc_gain = 1
        self.calib_2 = calib_2 = -342.774
        self.calib_1 = calib_1 = 4.0755e3
        self.add_noise = add_noise = 0

        ##################################################
        # Blocks
        ##################################################
        self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP)
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel")
        self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements")
        self.Add(self.Main)
        _spavg_sizer = wx.BoxSizer(wx.VERTICAL)
        self._spavg_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	label="Spectral Averaging (Seconds)",
        	converter=forms.int_converter(),
        	proportion=0,
        )
        self._spavg_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_spavg_sizer,
        	value=self.spavg,
        	callback=self.set_spavg,
        	minimum=1,
        	maximum=20,
        	num_steps=20,
        	style=wx.SL_HORIZONTAL,
        	cast=int,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1)
        self._rec_button_tpr_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_tpr,
        	callback=self.set_rec_button_tpr,
        	label="Record TPR Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1)
        self._rec_button_iq_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.rec_button_iq,
        	callback=self.set_rec_button_iq,
        	label="Record I/Q Data",
        	choices=[0,1],
        	labels=['Stop','Start'],
        )
        self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1)
        _integ_sizer = wx.BoxSizer(wx.VERTICAL)
        self._integ_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	label="Integration Time (Seconds)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._integ_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_integ_sizer,
        	value=self.integ,
        	callback=self.set_integ,
        	minimum=1,
        	maximum=60,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1)
        _gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._gain_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	label="RF Gain (dB)",
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._gain_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_gain_sizer,
        	value=self.gain,
        	callback=self.set_gain,
        	minimum=0,
        	maximum=50,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1)
        self._freq_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Center Frequency (Hz)",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1)
        self._dc_gain_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.dc_gain,
        	callback=self.set_dc_gain,
        	label="DC Gain",
        	choices=[1, 10, 100, 1000, 10000],
        	labels=[],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1)
        self._calib_2_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_2,
        	callback=self.set_calib_2,
        	label="Calibration value 2",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1)
        self._calib_1_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.calib_1,
        	callback=self.set_calib_1,
        	label="Calibration value 1",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1)
        self._GUI_samp_rate_chooser = forms.radio_buttons(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.GUI_samp_rate,
        	callback=self.set_GUI_samp_rate,
        	label="Sample Rate (BW)",
        	choices=[1e6,2e6,5e6,10e6,25e6],
        	labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'],
        	style=wx.RA_HORIZONTAL,
        )
        self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1)
        self.wxgui_scopesink2_2 = scopesink2.scope_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	title="Total Power",
        	sample_rate=2,
        	v_scale=.1,
        	v_offset=0,
        	t_scale=100,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_STRIPCHART,
        	y_axis_label="power level",
        )
        self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win)
        self.wxgui_numbersink2_2 = numbersink2.number_sink_f(
        	self.GetWin(),
        	unit="Units",
        	minval=0,
        	maxval=1,
        	factor=1.0,
        	decimal_places=10,
        	ref_level=0,
        	sample_rate=GUI_samp_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Number Plot",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Add(self.wxgui_numbersink2_2.win)
        self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="",
        	minval=0,
        	maxval=.2,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=True,
        	avg_alpha=.01,
        	label="Raw Power level",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win)
        self.wxgui_numbersink2_0 = numbersink2.number_sink_f(
        	self.Main.GetPage(1).GetWin(),
        	unit="Kelvin",
        	minval=0,
        	maxval=400,
        	factor=1,
        	decimal_places=6,
        	ref_level=0,
        	sample_rate=scope_rate,
        	number_rate=15,
        	average=False,
        	avg_alpha=None,
        	label="Calibrated Temperature",
        	peak_hold=False,
        	show_gauge=True,
        )
        self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_c(
        	self.Main.GetPage(0).GetWin(),
        	baseband_freq=freq,
        	y_per_div=10,
        	y_divs=10,
        	ref_level=20,
        	ref_scale=2.0,
        	sample_rate=GUI_samp_rate,
        	fft_size=1024,
        	fft_rate=5,
        	average=True,
        	avg_alpha=0.1,
        	title="Spectrum",
        	peak_hold=False,
        	size=(800,400),
        )
        self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join((devid, "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(GUI_samp_rate)
        self.uhd_usrp_source_0.set_center_freq(freq, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        (self.uhd_usrp_source_0).set_processor_affinity([0])
        self._text_samp_rate_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_samp_rate,
        	callback=self.set_text_samp_rate,
        	label="Samp rate",
        	converter=forms.float_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1)
        self._text_deviceID_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_deviceID,
        	callback=self.set_text_deviceID,
        	label="SubDev",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1)
        self._text_Device_addr_static_text = forms.static_text(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.text_Device_addr,
        	callback=self.set_text_Device_addr,
        	label="Device Address",
        	converter=forms.str_converter(),
        )
        self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1)
        (self.single_pole_iir_filter_xx_0).set_processor_affinity([1])
        _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL)
        self._noise_amplitude_text_box = forms.text_box(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	label='noise_amplitude',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._noise_amplitude_slider = forms.slider(
        	parent=self.Main.GetPage(0).GetWin(),
        	sizer=_noise_amplitude_sizer,
        	value=self.noise_amplitude,
        	callback=self.set_noise_amplitude,
        	minimum=.01,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
        	sample_rate=samp_rate,
        	fft_size=fftsize,
        	ref_scale=2,
        	frame_rate=fftrate,
        	avg_alpha=1.0/float(spavg*fftrate),
        	average=True,
        )
        self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001)
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, ))
        self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate)
        self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate)
        self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate))
        self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False)
        self.blocks_file_sink_5.set_unbuffered(True)
        self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False)
        self.blocks_file_sink_4.set_unbuffered(True)
        self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False)
        self.blocks_file_sink_0.set_unbuffered(True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, ))
        self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq))
        self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr))
        self._add_noise_chooser = forms.button(
        	parent=self.Main.GetPage(0).GetWin(),
        	value=self.add_noise,
        	callback=self.set_add_noise,
        	label="Noise Source",
        	choices=[0,1],
        	labels=['Off','On'],
        )
        self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0))    
        self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0))    
        self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0))    
        self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0))    
        self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0))    
        self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0))    
        self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0))    
        self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0))    
        self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0))    
        self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0))    
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))    
        self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))    
Example #57
0
    def __init__(self, filenames, dev_addrs,
                 onebit, iq, noise, mix, gain, fs, fc, unint, sync_pps):
        gr.top_block.__init__(self)

        if mix:
            raise NotImplementedError("TODO: Hilbert remix mode not implemented.")

        uhd_sinks = [
            uhd.usrp_sink(",".join(
                [addr, "send_frame_size=32768,num_send_frames=128"]),
                          uhd.stream_args(
                              cpu_format="fc32",
                              otwformat="sc8",
                              channels=[0]))
            for addr in dev_addrs]

        for sink in uhd_sinks:
            sink.set_clock_rate(fs*2, uhd.ALL_MBOARDS)
            sink.set_samp_rate(fs)
            sink.set_center_freq(fc, 0)
            sink.set_gain(gain, 0)
            # TODO Use offset tuning?
            if sync_pps:
                sink.set_clock_source("external") # 10 MHz
                sink.set_time_source("external") # PPS

        if unint:
            if noise or onebit or not iq:
                raise NotImplementedError("TODO: RX channel-interleaved mode only "
                                          "supported for noiseless 8-bit complex.")
            
            BLOCK_N=16*1024*1024
            demux = blocks.vector_to_streams(2, len(uhd_sinks))
            self.connect(blocks.file_source(2*len(uhd_sinks)*BLOCK_N, filenames[0], False),
                         blocks.vector_to_stream(2*len(uhd_sinks), BLOCK_N),
                         demux)
            for ix, sink in enumerate(uhd_sinks):
                self.connect((demux, ix),
                             blocks.vector_to_stream(1, 2),
                             blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                             blocks.multiply_const_cc(1.0/1024), # [-0.125, 0.125)
#                             blocks.vector_to_stream(8, 16*1024),
                             sink)

        else:
            file_srcs = [blocks.file_source(gr.sizeof_char*1, f, False)
                         for f in filenames]

            for src, sink in zip(file_srcs, uhd_sinks):

                if iq:
                    node = blocks.multiply_const_cc(1.0/1024)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), 
                                     blocks.char_to_short(), # [0, 1] -> [0, 256]
                                     blocks.add_const_ss(-128), # [-128, +128],
                                     blocks.interleaved_short_to_complex(), # [ -128.0, +128.0]
                                     node) # [-0.125, +0.125]
                    else:
                        self.connect(src, # [-128..127]
                                     blocks.interleaved_char_to_complex(), # [-128.0, +127.0]
                                     node) # [-0.125, +0.125)
                    
                else:
                    node = blocks.float_to_complex(1)
                    if onebit:
                        self.connect(src,
                                     blocks.unpack_k_bits_bb(8), # [0, 1] -> [-0.125, +0.125]
                                     blocks.char_to_float(vlen=1, scale=4),
                                     blocks.add_const_vff((-0.125, )),
                                     node)
                    else:
                        self.connect(src, # [-128..127] -> [-0.125, +0.125)
                                     blocks.char_to_float(vlen=1, scale=1024),
                                     node)
                        
                if noise:
                    combiner = blocks.add_vcc(1)
                    self.connect(node,
                                 combiner,
                                 sink)
                    self.connect(analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise, -222, 8192),
                                 (combiner, 1))
                else:
                    self.connect(node,
                                 sink)

        print "Setting clocks..."
        if sync_pps:
            time.sleep(1.1) # Ensure there's been an edge.  TODO: necessary?
            last_pps_time = uhd_sinks[0].get_time_last_pps()
            while last_pps_time == uhd_sinks[0].get_time_last_pps():
                time.sleep(0.1)
            print "Got edge"
            [sink.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for sink in uhd_sinks]
            time.sleep(1.0) # Wait for edge to set the clocks
        else:
            # No external PPS/10 MHz.  Just set each clock and accept some skew.
            t = time.time()
            [sink.set_time_now(uhd.time_spec(time.time())) for sink in uhd_sinks]
            if len(uhd_sinks) > 1:
                print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % (
                    (time.time()-t) * 1000)

        t_start = uhd.time_spec(time.time() + 1.5)
        [sink.set_start_time(t_start) for sink in uhd_sinks]
        print "ready"