예제 #1
0
    def __init__(self,q_rx,q_tx,noise_voltage=0.01,frequency_offset=0.01,epsilon=1.001,taps=(1+0.5j, ),):
        '''Constructor.
        
        @param q_rx:
        '''
	samp_per_sym =5
        gr.top_block.__init__(self)
        self.sink_queue = gr.msg_queue()
        #self.Add(self.wxgui_scopesink2_0_0.win)
        self.hier_rx_0 = hier_rx.hier_rx(
            bw_clock_sync=2*math.pi/5,
            bw_fll=math.pi/400,
            bits_per_sym=2,
            bw_costas=2*math.pi/100,
            n_filts=32,
            len_sym_srrc=7,
            constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(),
            samp_per_sym=samp_per_sym,
            alfa=0.35,
        )
        
        
        self.hier_tx_0 = hier_tx.hier_tx(
            alfa=0.35,
            samp_per_sym=samp_per_sym,
            bits_per_sym=2,
            constellation=[-1-1j,1-1j, 1+1j, -1+1j],
            len_sym_srrc=7,
            out_const_mul=0.4,
        )

        #self.hier_rx_0 = hier_rx()
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage,
        	frequency_offset,
        	epsilon,
        	taps,
        	noise_seed=0,
        	block_tags=False
        )
        threshold = 12              # FIXME raise exception
        access_code = packet_utils.default_access_code
        

        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, 4)
        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        self.correlator = digital.correlate_access_code_bb( access_code, threshold)
        #"Arreglar access_code en la llamada a correlate""""""
        self.framer_sink = digital.framer_sink_1(self._rcvd_pktq)
        
        self.vsnk_src = blocks.vector_sink_b()
        self.m_sink   = blocks.message_sink(gr.sizeof_char*1, self.sink_queue,True)
        ##################################################
        # Connections
        ##################################################
        #self.connect((self.hier_tx_pencoder_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect(( self.blocks_message_source_0, 0),(self.hier_tx_0, 0) )
        self.connect((self.hier_tx_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.channels_channel_model_0, 0), (self.hier_rx_0, 0))        
        self.connect((self.hier_rx_0, 0), self.correlator, self.framer_sink)
        self._watcher = _queue_watcher_thread(self._rcvd_pktq,q_rx)
        queue = self.blocks_message_source_0.msgq()
        self.snd = SendData(q_tx,queue,samp_per_sym)   
예제 #2
0
    def __init__(self,q_rx,q_tx,samp_per_sym=3, antenna='TX/RX', \
        rx_freq=850000000.0, rx_gain=15.0, spec='A:0', tx_gain=15.0, \
        args='serial=E0R11Y0B1', bit_rate=100000.0, \
        tx_freq=851000000.0, tx_amplitude=0.25,):
        '''Constructor.
        TODO: I AM NOT SETTING the Tx_AMPLITUDE
        @param q_rx:
        '''
        gr.top_block.__init__(self)
        self.sink_queue = gr.msg_queue()
        bits_per_sym = 2   # only for QPSK!
        #samp_per_sym=3
        sym_rate = bit_rate/bits_per_sym 
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	device_addr=args,
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_subdev_spec(spec, 0)
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna(antenna, 0)
        self.set_sample_rate(self.uhd_usrp_source_0,sym_rate, samp_per_sym)

        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr=args,
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_subdev_spec(spec, 0)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna(antenna, 0)
        self.set_sample_rate(self.uhd_usrp_sink_0,sym_rate, samp_per_sym)

        #self.Add(self.wxgui_scopesink2_0_0.win)
        self.hier_rx_0 = hier_rx.hier_rx(
            bw_clock_sync=2*math.pi/100,
            bw_fll=2*math.pi/100,
            bits_per_sym=bits_per_sym,
            bw_costas=2*math.pi/100,
            n_filts=32,
            len_sym_srrc=11,
            constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(),
            samp_per_sym=samp_per_sym,
            alfa=0.45,
        )
        
        
        self.hier_tx_0 = hier_tx.hier_tx(
            alfa=0.45,
            samp_per_sym=samp_per_sym,
            constellation=[-1-1j,1-1j, 1+1j, -1+1j],
            len_sym_srrc=11,
            out_const_mul=0.4,
            bits_per_sym=bits_per_sym,
        )


        threshold = 12              # FIXME raise exception
        access_code = packet_utils.default_access_code
    
        self.blocks_message_source_0 = blocks.message_source(gr.sizeof_char*1, 4)
        self._rcvd_pktq = gr.msg_queue()          # holds packets from the PHY
        self.correlator = digital.correlate_access_code_bb( access_code, threshold)
        #"Arreglar access_code en la llamada a correlate""""""
        self.framer_sink = digital.framer_sink_1(self._rcvd_pktq)
        
        self.vsnk_src = blocks.vector_sink_b()
        self.m_sink   = blocks.message_sink(gr.sizeof_char*1, self.sink_queue,True)
        ##################################################
        # Connections
        ##################################################
        #self.connect((self.hier_tx_pencoder_0, 0), (self.wxgui_scopesink2_0_0, 0))
        self.connect(( self.blocks_message_source_0, 0),(self.hier_tx_0, 0) )
        self.connect((self.hier_tx_0, 0), (self.uhd_usrp_sink_0, 0))

        self.connect((self.uhd_usrp_source_0, 0), (self.hier_rx_0, 0))
        self.connect((self.hier_rx_0, 0), self.correlator, self.framer_sink)
        self._watcher = _queue_watcher_thread(self._rcvd_pktq,q_rx)
        queue = self.blocks_message_source_0.msgq()
        self.snd = SendData(q_tx,queue,samp_per_sym)