Esempio n. 1
0
    def __init__(self,
                 sps,               # Samples per symbol
                 excess_bw,         # RRC filter excess bandwidth (typically 0.35-0.5)
                 amplitude,         # DAC output level, 0-32767, typically 2000-8000
                 vector_source,   # Indicate if it's the infinite sequence of 1, or by use the code to change the amplitude
                 ):

            gr.hier_block2.__init__(self, "bpsk_modulator",
                                gr.io_signature(0, 0, 0),                    # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
            
            # Create BERT data bit stream	
            
            self.vector_source = vector_source
            
            self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 31) # CCSDS 7-bit scrambler
            
            # Map to constellation
            self._constellation = [-1+0j, 1+0j]
            self._mapper = gr.chunks_to_symbols_bc(self._constellation)	
            
            # Create RRC with specified excess bandwidth
            taps = gr.firdes.root_raised_cosine(sps,  # Gain
					    sps,	    # Sampling rate
					    1.0,	    # Symbol rate
					    excess_bw,	    # Roll-off factor
					    11*sps)         # Number of taps
            
            self._rrc = gr.interp_fir_filter_ccf(sps,	    # Interpolation rate
					     taps)	    # FIR taps
            
            self.amp = gr.multiply_const_cc(amplitude)
            
            # Wire block inputs and outputs
            self.connect(self.vector_source, self._scrambler, self._mapper, self._rrc, self.amp, self)
Esempio n. 2
0
def key_factory(index):
    print "FACTORY CALLED index = %d"%(index);
    
    r = es.es_pyhandler();

    excess_bw = 0.5;
    sps = 4;
    amplitude = sig_amp;
    taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
                        sps,        # Sampling rate
                        1.0,        # Symbol rate
                        excess_bw,      # Roll-off factor
                        11*sps)         # Number of taps

    blocks = {};
    blocks["src"] = es.vector_source([1]) 
    blocks["scrambler"] = gr.scrambler_bb(0x8A, 0x7F, 7);
    blocks["mapper"] = gr.chunks_to_symbols_bc( [-1+0j, 0+1j, 1+0j, 0-1j] );
    blocks["rrc"] = gr.interp_fir_filter_ccf(sps, taps);
    r.sink = es.vector_sink([gr.sizeof_gr_complex]);
    r.set_pyb2(blocks);

    tb  = gr.top_block();
    tb.connect( blocks["src"], blocks["scrambler"], blocks["mapper"], blocks["rrc"], r.sink );

    r.tb = tb.to_top_block();
    return r;
Esempio n. 3
0
    def __init__(self,
                 sps,          # Samples per symbol
                 excess_bw,    # RRC filter excess bandwidth (typically 0.35-0.5)
                 amplitude     # DAC output level, 0-32767, typically 2000-8000
                 ):

        gr.hier_block2.__init__(self, "transmit_path",
                                gr.io_signature(0, 0, 0),                    # Input signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature

        # Create BERT data bit stream	
	self._bits = gr.vector_source_b([1,], True)      # Infinite stream of ones
        self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler

	# Map to constellation
	self._constellation = [-1+0j, 1+0j]
	self._mapper = gr.chunks_to_symbols_bc(self._constellation)	

	# Create RRC with specified excess bandwidth
	taps = gr.firdes.root_raised_cosine(sps*amplitude,  # Gain
					    sps,	    # Sampling rate
					    1.0,	    # Symbol rate
					    excess_bw,	    # Roll-off factor
					    11*sps)         # Number of taps

	self._rrc = gr.interp_fir_filter_ccf(sps,	    # Interpolation rate
					     taps)	    # FIR taps

        # Wire block inputs and outputs
        self.connect(self._bits, self._scrambler, self._mapper, self._rrc, self)
Esempio n. 4
0
 def test_scrambler_descrambler(self):
     src_data = (1,)*1000
     src = gr.vector_source_b(src_data, False)
     scrambler = gr.scrambler_bb(0x8a, 0x7F, 7)     # CCSDS 7-bit scrambler
     descrambler = gr.descrambler_bb(0x8a, 0x7F, 7) 
     dst = gr.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
Esempio n. 5
0
 def test_scrambler_descrambler(self):
     src_data = (1,)*1000
     src = gr.vector_source_b(src_data, False)
     scrambler = gr.scrambler_bb(0x8a, 0x7F, 7)     # CCSDS 7-bit scrambler
     descrambler = gr.descrambler_bb(0x8a, 0x7F, 7)
     dst = gr.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
Esempio n. 6
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.gr_char_to_float_0 = gr.char_to_float()
        self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7)
        self.gr_throttle_0 = gr.throttle(gr.sizeof_char * 1, samp_rate)
        self.gr_vector_source_x_0 = gr.vector_source_b((0, 0, 0), True, 1)
        self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
            self.GetWin(),
            baseband_freq=0,
            y_per_div=10,
            y_divs=10,
            ref_level=50,
            ref_scale=2.0,
            sample_rate=samp_rate,
            fft_size=1024,
            fft_rate=30,
            average=False,
            avg_alpha=None,
            title="FFT Plot",
            peak_hold=False,
        )
        self.Add(self.wxgui_fftsink2_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=samp_rate,
            v_scale=1,
            v_offset=0,
            t_scale=0005,
            ac_couple=False,
            xy_mode=False,
            num_inputs=1,
        )
        self.Add(self.wxgui_scopesink2_0.win)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.gr_scrambler_bb_0, 0), (self.gr_char_to_float_0, 0))
        self.connect((self.gr_char_to_float_0, 0), (self.wxgui_fftsink2_0, 0))
        self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0, 0))
        self.connect((self.gr_throttle_0, 0), (self.gr_scrambler_bb_0, 0))
        self.connect((self.gr_char_to_float_0, 0),
                     (self.wxgui_scopesink2_0, 0))
Esempio n. 7
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Top Block")
		_icon_path = "/home/pfb/.local/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

		##################################################
		# Blocks
		##################################################
		self.gr_char_to_float_0 = gr.char_to_float()
		self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_char*1, samp_rate)
		self.gr_vector_source_x_0 = gr.vector_source_b((0, 0, 0), True, 1)
		self.wxgui_fftsink2_0 = fftsink2.fft_sink_f(
			self.GetWin(),
			baseband_freq=0,
			y_per_div=10,
			y_divs=10,
			ref_level=50,
			ref_scale=2.0,
			sample_rate=samp_rate,
			fft_size=1024,
			fft_rate=30,
			average=False,
			avg_alpha=None,
			title="FFT Plot",
			peak_hold=False,
		)
		self.Add(self.wxgui_fftsink2_0.win)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_f(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate,
			v_scale=1,
			v_offset=0,
			t_scale=0005,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
		)
		self.Add(self.wxgui_scopesink2_0.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_scrambler_bb_0, 0), (self.gr_char_to_float_0, 0))
		self.connect((self.gr_char_to_float_0, 0), (self.wxgui_fftsink2_0, 0))
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.gr_throttle_0, 0), (self.gr_scrambler_bb_0, 0))
		self.connect((self.gr_char_to_float_0, 0), (self.wxgui_scopesink2_0, 0))
Esempio n. 8
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Top Block")
		_icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
		self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 1000

		##################################################
		# Blocks
		##################################################
		self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0)
		self.gr_descrambler_bb_0 = gr.descrambler_bb(0x8A, 0x7F, 7)
		self.gr_float_to_complex_0 = gr.float_to_complex(1)
		self.gr_packed_to_unpacked_xx_0 = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
		self.gr_scrambler_bb_0 = gr.scrambler_bb(0x8A, 0x7F, 7)
		self.gr_throttle_0 = gr.throttle(gr.sizeof_gr_complex*1, samp_rate)
		self.gr_throttle_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate)
		self.gr_throttle_0_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate*8)
		self.gr_throttle_0_0_0_0 = gr.throttle(gr.sizeof_char*1, samp_rate*8*8)
		self.gr_uchar_to_float_0 = gr.uchar_to_float()
		self.gr_unpacked_to_packed_xx_0 = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
		self.gr_vector_source_x_0 = gr.vector_source_b((0, 1, 3,7,255,3,1,0), True, 1)
		self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
			self.GetWin(),
			title="Scope Plot",
			sample_rate=samp_rate*32,
			v_scale=0,
			v_offset=0,
			t_scale=0,
			ac_couple=False,
			xy_mode=False,
			num_inputs=1,
		)
		self.Add(self.wxgui_scopesink2_0.win)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_float_to_complex_0, 0), (self.gr_throttle_0, 0))
		self.connect((self.const_source_x_0, 0), (self.gr_float_to_complex_0, 1))
		self.connect((self.gr_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
		self.connect((self.gr_vector_source_x_0, 0), (self.gr_throttle_0_0, 0))
		self.connect((self.gr_throttle_0_0, 0), (self.gr_packed_to_unpacked_xx_0, 0))
		self.connect((self.gr_descrambler_bb_0, 0), (self.gr_unpacked_to_packed_xx_0, 0))
		self.connect((self.gr_packed_to_unpacked_xx_0, 0), (self.gr_throttle_0_0_0, 0))
		self.connect((self.gr_throttle_0_0_0, 0), (self.gr_scrambler_bb_0, 0))
		self.connect((self.gr_scrambler_bb_0, 0), (self.gr_throttle_0_0_0_0, 0))
		self.connect((self.gr_throttle_0_0_0_0, 0), (self.gr_descrambler_bb_0, 0))
		self.connect((self.gr_uchar_to_float_0, 0), (self.gr_float_to_complex_0, 0))
		self.connect((self.gr_unpacked_to_packed_xx_0, 0), (self.gr_uchar_to_float_0, 0))
Esempio n. 9
0
    def __init__(self, constellation, samples_per_symbol,
                 differential, excess_bw, gray_coded,
                 verbose, log):

        gr.hier_block2.__init__(self, "bert_transmit",
                                gr.io_signature(0, 0, 0),                    # Output signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature
        
        # Create BERT data bit stream	
	self._bits = gr.vector_source_b([1,], True)      # Infinite stream of ones
        self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, samples_per_symbol,
                                        differential, excess_bw, gray_coded,
                                        verbose, log)

        self._pack = gr.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
    def __init__(self, constellation, samples_per_symbol,
                 differential, excess_bw, gray_coded,
                 verbose, log):

        gr.hier_block2.__init__(self, "bert_transmit",
                                gr.io_signature(0, 0, 0),                    # Output signature
                                gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Input signature
        
        # Create BERT data bit stream	
	self._bits = gr.vector_source_b([1,], True)      # Infinite stream of ones
        self._scrambler = gr.scrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit scrambler

        self._mod = digital.generic_mod(constellation, samples_per_symbol,
                                        differential, excess_bw, gray_coded,
                                        verbose, log)

        self._pack = gr.unpacked_to_packed_bb(self._mod.bits_per_symbol(), gr.GR_MSB_FIRST)

        self.connect(self._bits, self._scrambler, self._pack, self._mod, self)
Esempio n. 11
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Communication System Graphical Analyzer (LAPS/UFCG)")
        
        ##################################################
        # Default Variables
        ##################################################
        self.sps = 2
        self.snr = 20
        self.symbol_rate = 140000
        self.mod_type = "DBPSK"
        self.view = 1
        self.band= 200
        self.excess_bw=0.35
        self.fading_flag = False 
        self.fdts = -8
        self.fading_state_rx = False
        
        ##################################################
        # Blocks Definition
        ##################################################
        
        #A bit stream of 1's is generated at the source, scrambled,
        #modulated and sent to the input of an AWGN channel.
        #random.seed(42)
        #self.source = gr.vector_source_b([random.randint(0, 2) for i in range(0,10^8)], True)
        self.source = gr.vector_source_b((1,), True, 1)
        self.thottle = gr.throttle(gr.sizeof_char,10e5)
        self.scrambler = gr.scrambler_bb(0x40801, 0x92F72, 20) #Taxa de simbolos constante
        self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.modulator = utils.mods[self.mod_type](self.sps,excess_bw=self.excess_bw)
        self.channel = utils.channel(1/10.0**(self.snr/10.0),self.band,self.symbol_rate,self.sps)
        
        #The noisy signal is demodulated, descrambled and the BER
        #is estimated by the ber_estim block using the receiver
        #density of 0 bits.
        self.demodulator = utils.demods[self.mod_type](self.sps,excess_bw=self.excess_bw)     
        self.descrambler = gr.descrambler_bb(0x40801, 0x92F72, 20)
        self.char2float = gr.char_to_float()
        self.mov_average = gr.moving_average_ff(524288, 1/524288., 10000)
        self.ber = utils.ber_estim()
        #self.ber = utils.ber_estim_simple(3)

        
        ##################################################
        # GUI Elements Definition
        ##################################################
        
        #Defines an adds FFT Window to GUI
        self.fft = fftsink.fft_sink_c(self.GetWin(), sample_rate=self.symbol_rate*self.sps, baseband_freq=5e6)
        self.GridAdd(self.fft.win, 0,3,4,3)
        self.ctr= gr.complex_to_real(1)
        
        #Defines and adds SNR slider to GUI
        _snr_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._snr_text_box = forms.text_box(parent=self.GetWin(),
            sizer=_snr_sizer, value=self.snr, callback=self.callback_snr,
            label=" SNR (dB)", converter=forms.float_converter(),
            proportion=0)
        self._snr_slider = forms.slider(parent=self.GetWin(),
            sizer=_snr_sizer, value=self.snr, callback=self.callback_snr,
            minimum=0, maximum=20, style=wx.RA_HORIZONTAL, proportion=1)
        self.GridAdd(_snr_sizer, 4, 3, 1, 3)
        
        #Defines and adds bandwidth slider to GUI
        band_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.band_text_box = forms.text_box(parent=self.GetWin(),
            sizer=band_sizer, value=self.band, callback=self.callback_band,
            label="Bandwidth (kHz)", converter=forms.float_converter(),
            proportion=0)
        self.band_slider = forms.slider(parent=self.GetWin(),
            sizer=band_sizer, value=self.band, callback=self.callback_band,
            minimum=30, maximum=200, style=wx.RA_HORIZONTAL, proportion=1)
        self.GridAdd(band_sizer, 5, 3, 1, 3)
        
        #Defines and adds Rayleigh GUI elements
        
        fading_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.fading_text_box = forms.text_box(parent=self.GetWin(),
            sizer=fading_sizer, value=self.fdts, callback=self.callback_fading,
            label='Fading/log(FdTs)', converter=forms.float_converter(),
            proportion=0)
        self.fading_slider = forms.slider(parent=self.GetWin(),
            sizer=fading_sizer, value=self.fdts, callback=self.callback_fading,
            minimum=-8, maximum=-2, style=wx.RA_HORIZONTAL, proportion=1)
        self.GridAdd(fading_sizer, 6, 3, 1, 3)
        
        #Defines and adds modulation type chooser to GUI
        self._mod_type_chooser = forms.radio_buttons(parent=self.GetWin(),
            value=self.mod_type, callback=self.set_mod_type,
            label="Modulation", choices=["DBPSK", "DQPSK", "D8PSK"],
            labels=["DBPSK", "DQPSK", "D8PSK"], style=wx.RA_HORIZONTAL)
        self.GridAdd(self._mod_type_chooser, 7, 4, 1, 2)

        
        #Defines and adds signal source chooser
        self.sig_src_chooser = forms.radio_buttons(parent=self.GetWin(),
            value=self.view, callback=self.callback_view,
            label="Signal Source", choices=[0,1],
            labels=["Transmitter","Receiver"], style=wx.RA_VERTICAL)
        self.GridAdd(self.sig_src_chooser, 7,3,1,1)
        
        
        #Definition of the of constellation window and attachment to the GUI
        self.constel = constsink.const_sink_c(self.GetWin(),
            title="RX Constellation Plot",  sample_rate=self.symbol_rate,
            const_size=256, mod=self.mod_type)
        self.GridAdd(self.constel.win,0,0,8,3)
        
        
        #Definition of the constellation sink window and attachment to the GUI
        self.number_sink = bersink.number_sink_f(self.GetWin(),
            sample_rate=self.symbol_rate)
        self.GridAdd(self.number_sink.win,8,0,1,6)
        
        ##################################################
        # Blocks Connections
        ##################################################
        
        #The necessary block connections to the system work as described above.
        self.connect(self.source, self.scrambler , self.thottle, self.pack)
        #self.connect(self.source , self.thottle, self.pack)
        self.connect(self.pack, self.modulator, self.channel, self.demodulator)
        self.connect(self.channel, self.fft)
        self.connect(self.demodulator.diffdec, self.constel)
        self.connect(self.demodulator, self.descrambler, self.char2float, self.mov_average)
        self.connect(self.mov_average, self.ber, self.number_sink)
Esempio n. 12
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(
            self, title="Communication System Graphical Analyzer (LAPS/UFCG)")

        ##################################################
        # Default Variables
        ##################################################
        self.sps = 2
        self.snr = 20
        self.symbol_rate = 140000
        self.mod_type = "DBPSK"
        self.view = 1
        self.band = 200
        self.excess_bw = 0.35
        self.fading_flag = False
        self.fdts = -8
        self.fading_state_rx = False

        ##################################################
        # Blocks Definition
        ##################################################

        #A bit stream of 1's is generated at the source, scrambled,
        #modulated and sent to the input of an AWGN channel.
        #random.seed(42)
        #self.source = gr.vector_source_b([random.randint(0, 2) for i in range(0,10^8)], True)
        self.source = gr.vector_source_b((1, ), True, 1)
        self.thottle = gr.throttle(gr.sizeof_char, 10e5)
        self.scrambler = gr.scrambler_bb(0x40801, 0x92F72,
                                         20)  #Taxa de simbolos constante
        self.pack = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.modulator = utils.mods[self.mod_type](self.sps,
                                                   excess_bw=self.excess_bw)
        self.channel = utils.channel(1 / 10.0**(self.snr / 10.0), self.band,
                                     self.symbol_rate, self.sps)

        #The noisy signal is demodulated, descrambled and the BER
        #is estimated by the ber_estim block using the receiver
        #density of 0 bits.
        self.demodulator = utils.demods[self.mod_type](
            self.sps, excess_bw=self.excess_bw)
        self.descrambler = gr.descrambler_bb(0x40801, 0x92F72, 20)
        self.char2float = gr.char_to_float()
        self.mov_average = gr.moving_average_ff(524288, 1 / 524288., 10000)
        self.ber = utils.ber_estim()
        #self.ber = utils.ber_estim_simple(3)

        ##################################################
        # GUI Elements Definition
        ##################################################

        #Defines an adds FFT Window to GUI
        self.fft = fftsink.fft_sink_c(self.GetWin(),
                                      sample_rate=self.symbol_rate * self.sps,
                                      baseband_freq=5e6)
        self.GridAdd(self.fft.win, 0, 3, 4, 3)
        self.ctr = gr.complex_to_real(1)

        #Defines and adds SNR slider to GUI
        _snr_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._snr_text_box = forms.text_box(parent=self.GetWin(),
                                            sizer=_snr_sizer,
                                            value=self.snr,
                                            callback=self.callback_snr,
                                            label=" SNR (dB)",
                                            converter=forms.float_converter(),
                                            proportion=0)
        self._snr_slider = forms.slider(parent=self.GetWin(),
                                        sizer=_snr_sizer,
                                        value=self.snr,
                                        callback=self.callback_snr,
                                        minimum=0,
                                        maximum=20,
                                        style=wx.RA_HORIZONTAL,
                                        proportion=1)
        self.GridAdd(_snr_sizer, 4, 3, 1, 3)

        #Defines and adds bandwidth slider to GUI
        band_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.band_text_box = forms.text_box(parent=self.GetWin(),
                                            sizer=band_sizer,
                                            value=self.band,
                                            callback=self.callback_band,
                                            label="Bandwidth (kHz)",
                                            converter=forms.float_converter(),
                                            proportion=0)
        self.band_slider = forms.slider(parent=self.GetWin(),
                                        sizer=band_sizer,
                                        value=self.band,
                                        callback=self.callback_band,
                                        minimum=30,
                                        maximum=200,
                                        style=wx.RA_HORIZONTAL,
                                        proportion=1)
        self.GridAdd(band_sizer, 5, 3, 1, 3)

        #Defines and adds Rayleigh GUI elements

        fading_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.fading_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=fading_sizer,
            value=self.fdts,
            callback=self.callback_fading,
            label='Fading/log(FdTs)',
            converter=forms.float_converter(),
            proportion=0)
        self.fading_slider = forms.slider(parent=self.GetWin(),
                                          sizer=fading_sizer,
                                          value=self.fdts,
                                          callback=self.callback_fading,
                                          minimum=-8,
                                          maximum=-2,
                                          style=wx.RA_HORIZONTAL,
                                          proportion=1)
        self.GridAdd(fading_sizer, 6, 3, 1, 3)

        #Defines and adds modulation type chooser to GUI
        self._mod_type_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.mod_type,
            callback=self.set_mod_type,
            label="Modulation",
            choices=["DBPSK", "DQPSK", "D8PSK"],
            labels=["DBPSK", "DQPSK", "D8PSK"],
            style=wx.RA_HORIZONTAL)
        self.GridAdd(self._mod_type_chooser, 7, 4, 1, 2)

        #Defines and adds signal source chooser
        self.sig_src_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.view,
            callback=self.callback_view,
            label="Signal Source",
            choices=[0, 1],
            labels=["Transmitter", "Receiver"],
            style=wx.RA_VERTICAL)
        self.GridAdd(self.sig_src_chooser, 7, 3, 1, 1)

        #Definition of the of constellation window and attachment to the GUI
        self.constel = constsink.const_sink_c(self.GetWin(),
                                              title="RX Constellation Plot",
                                              sample_rate=self.symbol_rate,
                                              const_size=256,
                                              mod=self.mod_type)
        self.GridAdd(self.constel.win, 0, 0, 8, 3)

        #Definition of the constellation sink window and attachment to the GUI
        self.number_sink = bersink.number_sink_f(self.GetWin(),
                                                 sample_rate=self.symbol_rate)
        self.GridAdd(self.number_sink.win, 8, 0, 1, 6)

        ##################################################
        # Blocks Connections
        ##################################################

        #The necessary block connections to the system work as described above.
        self.connect(self.source, self.scrambler, self.thottle, self.pack)
        #self.connect(self.source , self.thottle, self.pack)
        self.connect(self.pack, self.modulator, self.channel, self.demodulator)
        self.connect(self.channel, self.fft)
        self.connect(self.demodulator.diffdec, self.constel)
        self.connect(self.demodulator, self.descrambler, self.char2float,
                     self.mov_average)
        self.connect(self.mov_average, self.ber, self.number_sink)
    def __init__(self, principal_gui, options):
        '''
        See below for what options should hold
        '''
        gr.hier_block2.__init__(self, "transmit_path",
                gr.io_signature(0, 0, 0),                    # Input signature
                gr.io_signature(0, 0, 0)) # Output signature
        
        options = copy.copy(options)    # make a copy so we can destructively modify

        self._verbose            = options.verbose
        self._tx_amplitude       = options.tx_amplitude    # digital amplitude sent to USRP
        self._bitrate            = options.rate        # desired bit rate
        self._samples_per_symbol = options.sps  # desired samples/baud

        #setup usrp
        self._setup_usrp_sink(options)
        
        #create a BPSK modulator 
        self.modulator = bpsk_modulator(principal_gui, options)         # the modulator we are using
        
        #create packet input like in ieee 802.15.4
        #the size of the queue is 2 messages 
        #######################*************
        msgq_limit = 10
        self.pkt_input = gr.message_source(gr.sizeof_char, msgq_limit)
             
        #The same chain like in ieee transceiver
        #add gain like in ieee802.15.4
        #######################################*****************
        #self.normal_gain = 8000
        #self.gain = gr.multiply_const_cc (self.normal_gain)
    
        self.amp = gr.multiply_const_cc(options.amplitude)
        #self.set_tx_amplitude(self._tx_amplitude)

        # Display some information about the setup
        if self._verbose:
            self._print_verbage()

        # Connect components in the flowgraph
        #self.connect(self.packet_transmitter, self.amp, self)
#        self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c(
#            principal_gui.GetWin(),
#            title="Constellation Plot",
#            sample_rate=options.samp_rate,
#            frame_rate=5,
#            const_size=2048,
#            M=2,
#            theta=0,
#            fmax=0.06,
#            mu=0.5,
#            gain_mu=0.005,
#            symbol_rate=options.samp_rate/self._samples_per_symbol,
#            omega_limit=0.005,
#        )
#        principal_gui.Add(self.wxgui_constellationsink2_0.win)
        
        '''For Stream of bits '''
        self.vector_source = gr.vector_source_b([1,], True)
        self.scrambler = gr.scrambler_bb(0x10,0x7F,7)
        #self.connect(self.vector_source,self.scrambler, self.modulator, self.amp, self.u)
        #self.connect(self.modulator,self.wxgui_constellationsink2_0)
        '''End For Stream of bits '''
        
        
        self.connect(self.pkt_input, self.modulator, self.amp, self.u)