コード例 #1
0
	def _setup_source(self, options):
	        self.symbol_rate=2; #for bpsk will edit the code later to set this automaticly based on the selected modulation scheme
	        self.u=uhd_receiver(options.args, self.symbol_rate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
コード例 #2
0
ファイル: rx_mimo.py プロジェクト: WindyCitySDR/gr-ofdm
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            if options.rx_ant == 1:
                self.source = uhd_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source,options.verbose)
            else:
                self.source = uhd_mimo_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source, options.verbose)
        elif(options.from_file is not None):
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)
        if (options.rx_ant == 1):
            self._setup_rx_path(options)
            self._setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.connect((self.source,0), self.dst)
        else:
            self._setup_rx_path(options)
            self._setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.dst2     = (self.rxpath,1)
            self.connect((self.source,0), self.dst)
            self.connect((self.source,1), self.dst2)
コード例 #3
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if(options.tx_freq is not None): 
            self.sink = uhd_transmitter(options.args,
                                       options.bandwidth, options.tx_freq, 
                                       options.lo_offset, options.tx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
#        elif(options.to_file is not None):
#            self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = blocks.null_sink(gr.sizeof_gr_complex)

        if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args,
                                       options.bandwidth, options.rx_freq, 
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
#        elif(options.from_file is not None):
#            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)


        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)
        self.txpath = transmit_path(options)

        self.connect(self.source, self.rxpath)
        self.connect(self.txpath, self.sink)
コード例 #4
0
ファイル: tunnel.py プロジェクト: manuts/stop-and-wait-arq
    def __init__(self, mod_class, demod_class,
                 rx_callback, options):

        gr.top_block.__init__(self)

        # Get the modulation's bits_per_symbol
        args = mod_class.extract_kwargs_from_options(options)
        symbol_rate = options.bitrate / mod_class(**args).bits_per_symbol()

        self.source = uhd_receiver(options.args, symbol_rate,
                                   options.samples_per_symbol,
                                   options.rx_freq, options.rx_gain,
                                   options.spec, options.antenna,
                                   options.verbose)
        
        self.sink = uhd_transmitter(options.args, symbol_rate,
                                    options.samples_per_symbol,
                                    options.tx_freq, options.tx_gain,
                                    options.spec, options.antenna,
                                    options.verbose)
        
        options.samples_per_symbol = self.source._sps

        self.txpath = transmit_path(mod_class, options)
        self.rxpath = receive_path(demod_class, rx_callback, options)
        self.connect(self.txpath, self.sink)
        self.connect(self.source, self.rxpath)
コード例 #5
0
ファイル: tunnel.py プロジェクト: Gibran000/gnuradio
    def __init__(self, mod_class, demod_class, rx_callback, options):

        gr.top_block.__init__(self)

        # Get the modulation's bits_per_symbol
        args = mod_class.extract_kwargs_from_options(options)
        symbol_rate = options.bitrate / mod_class(**args).bits_per_symbol()

        self.source = uhd_receiver(options.args, symbol_rate,
                                   options.samples_per_symbol, options.rx_freq,
                                   options.rx_gain, options.spec,
                                   options.antenna, options.verbose)

        self.sink = uhd_transmitter(options.args, symbol_rate,
                                    options.samples_per_symbol,
                                    options.tx_freq, options.tx_gain,
                                    options.spec, options.antenna,
                                    options.verbose)

        options.samples_per_symbol = self.source._sps

        self.txpath = transmit_path(mod_class, options)
        self.rxpath = receive_path(demod_class, rx_callback, options)
        self.connect(self.txpath, self.sink)
        self.connect(self.source, self.rxpath)
コード例 #6
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()
            ask_sample_rate = symbol_rate*options.samples_per_symbol

            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol, options.rx_freq, 
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
<<<<<<< HEAD
                                       options.verbose)
                                       
            self.source.u.set_start_on_demand()
            #options.samples_per_symbol = self.source._sps
            #devices = uhd.find_devices_raw()
            #addr0 = devices[0].to_string()
            #self.source = uhd_sensor(addr0[11:30], ask_sample_rate,
            #                       options.sx_freq, options.sx_gain,
            #                       options.sx_spec, options.sx_antenna, 
            #                        options.verbose)
                                   
            #self.sampcov = digital.digital_swig.sampcov_matrix_calculator(ds,800,16)
            #self.sampcov = digital.digital_swig.sampcov_matrix_generator(ds,800)
            #self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex, ds*800)
            #self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex, ds*800) 
            #self.tracer = digital.digital_swig.trace_calculator(ds)
            #self.gr_file_sink3 = gr.file_sink(gr.sizeof_float, "/home/alexzh/Dropbox/Public/trace.dat")
            #self.gr_file_sink4 = gr.file_sink(gr.sizeof_float*ds, "eigenvalue.dat")
            self.gr_file_sink5 = gr.file_sink(gr.sizeof_gr_complex, "file.dat")
コード例 #7
0
    def __init__(self, rx_callback):
        gr.top_block.__init__(self)

        self.mod_type = "bpsk"  # bpsk or qpsk
        if (self.mod_type == "bpsk"):
            self.bits = 1
        else:
            self.bits = 2
        self.samples_per_symbol = 4
        self.bit_rate = 100000
        self.symbol_rate = self.bit_rate / self.bits

        self.freq = 1000000000.0

        self.source = uhd_receiver(sym_rate=self.symbol_rate,
                                   sps=self.samples_per_symbol,
                                   freq=self.freq,
                                   verbose=True)

        self.recv = receive_path(self.samples_per_symbol, self.mod_type,
                                 rx_callback, 30.0, "HLS_LS")

        self.connect(self.source, self.recv)

        self.write_data()
コード例 #8
0
ファイル: rx_voice.py プロジェクト: manuts/stop-and-wait-arq
    def __init__(self, demod_class, rx_callback, options):
        gr.top_block.__init__(self)
        self.rxpath = receive_path(demod_class, rx_callback, options)
        self.audio_tx = audio_tx(options.audio_output)

        if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bitrate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.antenna, options.verbose)
            options.samples_per_symbol = self.source._sps

            audio_rate = self.audio_tx.sample_rate
            usrp_rate = self.source.get_sample_rate()
            rrate = audio_rate / usrp_rate
            self.resampler = blks2.pfb_arb_resampler_ccf(rrate)
            
            self.connect(self.source, self.resampler, self.rxpath)

        elif(options.from_file is not None):
            self.thr = gr.throttle(gr.sizeof_gr_complex, options.bitrate)
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
            self.connect(self.source, self.thr, self.rxpath)

        else:
            self.thr = gr.throttle(gr.sizeof_gr_complex, 1e6)
            self.source = gr.null_source(gr.sizeof_gr_complex)
            self.connect(self.source, self.thr, self.rxpath)

	self.connect(self.audio_tx)        
コード例 #9
0
ファイル: tunnel.py プロジェクト: Wysaat/gnuradio
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.source = uhd_receiver(
            options.args,
            options.bandwidth,
            options.rx_freq,
            options.rx_gain,
            options.spec,
            options.antenna,
            options.verbose,
        )

        self.sink = uhd_transmitter(
            options.args,
            options.bandwidth,
            options.tx_freq,
            options.tx_gain,
            options.spec,
            options.antenna,
            options.verbose,
        )

        self.txpath = transmit_path(options)
        self.rxpath = receive_path(callback, options)

        self.connect(self.txpath, self.sink)
        self.connect(self.source, self.rxpath)
コード例 #10
0
ファイル: new_receiver.py プロジェクト: CheYuLu/DSA
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if (options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
        elif (options.from_file is not None):
            self.source = gr.file_source(gr.sizeof_gr_complex,
                                         options.from_file)
        else:
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        if (options.tx_freq is not None):
            self.sink = uhd_transmitter(options.args, options.bandwidth,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
        elif (options.to_file is not None):
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = gr.null_sink(gr.sizeof_gr_complex)
        self.source.set_sample_rate(1500000)  #rx sample rate
        self.sink.set_sample_rate(640000)
        self.rxpath = receive_path(callback, options)
        self.txpath = transmit_path(options)
        self.connect(self.source, self.rxpath)
        self.connect(self.txpath, self.sink)
        self.source.set_antenna("RX2")
        global freq
        freq = options.tx_freq  # - 12e6
コード例 #11
0
 def _setup_source(self, options):
     self.symbol_rate = 2
     #for bpsk will edit the code later to set this automaticly based on the selected modulation scheme
     self.u = uhd_receiver(options.args, self.symbol_rate,
                           options.samples_per_symbol, options.rx_freq,
                           options.rx_gain, options.spec, options.antenna,
                           options.verbose)
コード例 #12
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if (options.freq is not None):
            self.source = uhd_receiver(options.args, options.bandwidth,
                                       options.freq, options.lo_offset,
                                       options.gain, options.spec,
                                       options.antenna, options.clock_source,
                                       options.verbose)
        elif (options.from_file is not None):
            self.source = blocks.file_source(gr.sizeof_gr_complex,
                                             options.from_file)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        self.connect(self.source, self.rxpath)

        # rpc server to receive remote commands
        self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("localhost", options.rpc_port), allow_none=True)
        self.xmlrpc_server.register_instance(self)
        threading.Thread(target=self.xmlrpc_server.serve_forever).start()
コード例 #13
0
  def __init__(self, options, callback=None):
    gr.top_block.__init__(self)
    if options.freq is not None:
      u = uhd_receiver(options.rx_args,
                       options.bandwidth,
                       options.rx_freq, options.rx_gain,
                       options.spec, options.antenna,
                       options.verbose, options.external)
      if options.bandwidth > 5e6:
        u.u.set_min_output_buffer(163840)

    elif options.infile is not None:
      u = blocks.file_source(gr.sizeof_gr_complex, options.infile)
    else:
      import sys
      sys.stderr.write("--freq or --infile must be specified\n")
      raise SystemExit
    self.callback = callback
    rx = ofdm_receive_path(options,self.callback)
    self.connect(u, rx)

    if options.profile:
      from gnuradio.ctrlport import monitor
      self.ctrlport_monitor = monitor()
      self.ctrlport_monitor_performance = monitor("gr-perf-monitorx")
コード例 #14
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()

            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol, options.rx_freq, 
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
            options.samples_per_symbol = self.source._sps

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = blocks.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(demodulator, rx_callback, options) 

        self.connect(self.source, self.rxpath)
コード例 #15
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if (options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose, options.external)
        elif (options.from_file is not None):
            self.source = gr.file_source(gr.sizeof_gr_complex,
                                         options.from_file)
        else:
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        self.connect(self.source, self.rxpath)

        if options.log:
            self.connect(
                self.source,
                gr.file_sink(gr.sizeof_gr_complex, 'rx_benchmark.dat'))
コード例 #16
0
ファイル: rx_voice.py プロジェクト: Gibran000/gnuradio
    def __init__(self, demod_class, rx_callback, options):
        gr.top_block.__init__(self)
        self.rxpath = receive_path(demod_class, rx_callback, options)
        self.audio_tx = audio_tx(options.audio_output)

        if (options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bitrate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.antenna, options.verbose)
            options.samples_per_symbol = self.source._sps

            audio_rate = self.audio_tx.sample_rate
            usrp_rate = self.source.get_sample_rate()
            rrate = audio_rate / usrp_rate
            self.resampler = filter.pfb.arb_resampler_ccf(rrate)

            self.connect(self.source, self.resampler, self.rxpath)

        elif (options.from_file is not None):
            self.thr = blocks.throttle(gr.sizeof_gr_complex, options.bitrate)
            self.source = blocks.file_source(gr.sizeof_gr_complex,
                                             options.from_file)
            self.connect(self.source, self.thr, self.rxpath)

        else:
            self.thr = blocks.throttle(gr.sizeof_gr_complex, 1e6)
            self.source = blocks.null_source(gr.sizeof_gr_complex)
            self.connect(self.source, self.thr, self.rxpath)

        self.connect(self.audio_tx)
コード例 #17
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        if (options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(
                **args).bits_per_symbol()

            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.lo_offset,
                                       options.rx_gain, options.spec,
                                       options.antenna, options.clock_source,
                                       options.verbose)
            options.samples_per_symbol = self.source._sps

        elif (options.from_file is not None):
            sys.stderr.write(
                ("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = blocks.file_source(gr.sizeof_gr_complex,
                                             options.from_file)
        else:
            sys.stderr.write(
                "No source defined, pulling samples from null source.\n\n")
            self.source = blocks.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(demodulator, rx_callback, options)

        self.connect(self.source, self.rxpath)
        print >> sys.stderr, options
コード例 #18
0
    def __init__(self,demodulator, rx_callback, options):

        gr.top_block.__init__(self)
        '''
        Constructor for top block of Power Estimator
        Creates the graph for calculating mean and variance
        '''

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()
        ########## Node 1 - USRP Source ##########
            self.u= uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
            #options.samples_per_symbol = self.source._sps


            self.rxpath = receive_path(demodulator, rx_callback, options)
        if options.type == 'Rx' or options.type=='Rx/S':
            self.connect(self.u, self.rxpath)

        ########## Node 2 - Data Statistic Generator ##########

        self.d = periodogram(options)

        ########## Connect - USRP to DS Generator ##########
        if options.type=='Rx/S' or options.type=='S':
            self.connect(self.u,self.d)
コード例 #19
0
ファイル: benchmark_txrx.py プロジェクト: UpYou/ofdm
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

	### Rx Side ###

        if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args_rx,
                                       options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
        elif(options.from_file is not None):
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = gr.null_source(gr.sizeof_gr_complex)


        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        
	## Tx Side ###
	if(options.tx_freq is not None):
            self.sink = uhd_transmitter(options.args_tx,
                                        options.bandwidth,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
        elif(options.to_file is not None):
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = gr.null_sink(gr.sizeof_gr_complex)


        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath = transmit_path(options)
        self.connect(self.txpath, self.sink)

#        self.txpath = gr.message_source(gr.sizeof_gr_complex, 3)
#        nco_sensitivity = 2.0/options.fft_length   # correct for fine frequency
#        self.nco = ftw.pnc_frequency_modulator_fc(nco_sensitivity)
#        self.connect(self.txpath, self.sink) # self.nco, 

	# if you use two USRPs and want to synchonized
	# need to change uhd_interface.py
#	self.source.config_mimo()
#	time.sleep(1)	# to make sync stable

	if options.debug:
	    self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx.dat'))	# Save reception signal 
	else:
	    self.connect(self.source, self.rxpath)
            #self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx.dat'))

	if(options.verbose):
            self._print_verbage()
コード例 #20
0
    def __init__(self, modulator, demodulator, rx_callback, options):
        gr.top_block.__init__(self)
		#parameters to sense channe
        #options.symbol_rate=2500000
        #options.samples_per_symbol=2
        #options.rx_freq=2500000000
        #options.rx_gain=20
        #options.chbw_factor=1
        sense_symbol_rate=2500000
        sense_samples_per_symbol=2
        sense_rx_freq=2500000000
        sense_rx_gain=20
        options.chbw_factor=1
	#options.samples_per_symbol,

 
        #args = demodulator.extract_kwargs_from_options(options)
        self.sensesource=uhd_receiver(options.args, sense_symbol_rate,
                                       sense_samples_per_symbol,
                                       sense_rx_freq, sense_rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)

        if(options.tx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = modulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / modulator(**args).bits_per_symbol()

            self.sink = uhd_transmitter(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
            options.samples_per_symbol = self.sink._sps
            
        elif(options.to_file is not None):
            sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file)))
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            sys.stderr.write("No sink defined, dumping samples to null sink.\n\n")
            self.sink = gr.null_sink(gr.sizeof_gr_complex)


        self.txgate = gr.copy(gr.sizeof_gr_complex)
        self.sensegate = gr.copy(gr.sizeof_gr_complex)
        #self.msgq             = gr.msg_queue()

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath = transmit_path(modulator, options)

        self.connect(self.txpath, self.txgate, self.sink)

	# do sense
        self.sensepath = sensing_path(options)

        self.tx_enabled = True
	self.sense_flag=False
	self.connect(self.sensesource, self.sensepath)
コード例 #21
0
ファイル: test_uci.py プロジェクト: teoyenmao/usrp_project
 def __init__(self, callback, options):
     gr.top_block.__init__(self)
     self.source = uhd_receiver(options.args,
                                options.bandwidth, options.rx_freq,
                                options.lo_offset, options.rx_gain,
                                options.spec, options.antenna,
                                options.clock_source, options.verbose)
     self.rxpath = receive_path(callback, options)
     self.connect(self.source, self.rxpath)
コード例 #22
0
ファイル: test_uci.py プロジェクト: chingwen823/xhint
 def __init__(self, callback, options):
     gr.top_block.__init__(self)
     self.source = uhd_receiver(options.args, options.bandwidth,
                                options.rx_freq, options.lo_offset,
                                options.rx_gain, options.spec,
                                options.antenna, options.clock_source,
                                options.verbose)
     self.rxpath = receive_path(callback, options)
     self.connect(self.source, self.rxpath)
コード例 #23
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        ### Rx Side ###

        if (options.rx_freq is not None):
            self.source = uhd_receiver(options.args_rx, options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
        elif (options.from_file is not None):
            self.source = gr.file_source(gr.sizeof_gr_complex,
                                         options.from_file)
        else:
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        ## Tx Side ###
        if (options.tx_freq is not None):
            self.sink = uhd_transmitter(options.args_tx, options.bandwidth,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
        elif (options.to_file is not None):
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = gr.null_sink(gr.sizeof_gr_complex)

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath = transmit_path(options)
        self.connect(self.txpath, self.sink)

        #        self.txpath = gr.message_source(gr.sizeof_gr_complex, 3)
        #        nco_sensitivity = 2.0/options.fft_length   # correct for fine frequency
        #        self.nco = ftw.pnc_frequency_modulator_fc(nco_sensitivity)
        #        self.connect(self.txpath, self.sink) # self.nco,

        # if you use two USRPs and want to synchonized
        # need to change uhd_interface.py
        #	self.source.config_mimo()
        #	time.sleep(1)	# to make sync stable

        if options.debug:
            self.connect(self.source,
                         gr.file_sink(gr.sizeof_gr_complex,
                                      'rx.dat'))  # Save reception signal
        else:
            self.connect(self.source, self.rxpath)
        #self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, 'rx.dat'))

        if (options.verbose):
            self._print_verbage()
コード例 #24
0
ファイル: rx.py プロジェクト: luwangg/gr-ofdm-1
    def __init__(self, options):
        gr.top_block.__init__(self)

        if (options.rx_freq is not None):
            if options.rx_ant == 1:
                self.source = uhd_receiver(
                    options.args, options.bandwidth, options.rx_freq,
                    options.lo_offset, options.rx_gain, options.spec,
                    options.antenna, options.clock_source, options.time_source,
                    options.verbose)
            else:
                self.source = uhd_mimo_receiver(
                    options.args, options.bandwidth, options.rx_freq,
                    options.lo_offset, options.rx_gain, options.spec,
                    options.antenna, options.clock_source, options.time_source,
                    options.verbose)
        elif (options.from_file is not None):
            self.file = blocks.file_source(gr.sizeof_gr_complex,
                                           options.from_file)
            self.source = blocks.throttle(gr.sizeof_gr_complex, 1e7)
            self.connect(self.file, self.source)
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)
        '''
        if options.tx_ant == 1:
            if options.rx_ant == 1:
                self.rxpath = receive_path(options)
                self._setup_rpc_manager()
                self.connect(self.source, self.rxpath)
            else:
                self.rxpath = receive_path_12(options)
                self._setup_rpc_manager()
                self.connect(self.source, self.rxpath)
                self.connect((self.source,1), (self.rxpath,1))
                '''
        if (options.rx_ant == 1):
            self._setup_rx_path(options)
            self.setup_rpc_manager()
            self.dst = (self.rxpath, 0)
            self.connect((self.source, 0), self.dst)
        else:
            self._setup_rx_path(options)
            self.setup_rpc_manager()
            self.dst = (self.rxpath, 0)
            self.dst2 = (self.rxpath, 1)
            self.connect((self.source, 0), self.dst)
            self.connect((self.source, 1), self.dst2)

        if options.scatterplot:
            print "Scatterplot enabled"
コード例 #25
0
ファイル: rx.py プロジェクト: WindyCitySDR/gr-ofdm
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            if options.rx_ant == 1:
                self.source = uhd_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source,options.verbose)
            else:
                self.source = uhd_mimo_receiver(options.args,
                                       options.bandwidth, options.rx_freq,
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.time_source, options.verbose)
        elif(options.from_file is not None):
            self.file = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
            self.source = blocks.throttle(gr.sizeof_gr_complex,1e7)
            self.connect( self.file, self.source )
        else:
            self.source = blocks.null_source(gr.sizeof_gr_complex)
        '''
        if options.tx_ant == 1:
            if options.rx_ant == 1:
                self.rxpath = receive_path(options)
                self._setup_rpc_manager()
                self.connect(self.source, self.rxpath)
            else:
                self.rxpath = receive_path_12(options)
                self._setup_rpc_manager()
                self.connect(self.source, self.rxpath)
                self.connect((self.source,1), (self.rxpath,1))
                '''
        if (options.rx_ant == 1):
            self._setup_rx_path(options)
            self.setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.connect((self.source,0), self.dst)
        else:
            self._setup_rx_path(options)
            self.setup_rpc_manager()
            self.dst    = (self.rxpath,0)
            self.dst2     = (self.rxpath,1)
            self.connect((self.source,0), self.dst)
            self.connect((self.source,1), self.dst2)

        if options.scatterplot:
          print "Scatterplot enabled"
コード例 #26
0
ファイル: cnPHY.py プロジェクト: ychang/gr-gtlib
    def __init__(self, rx_callback, options):
        gr.top_block.__init__(self)

        # Setting up 'Transmit Path'
        self.txpath = transmit_path(options, self)

        # Setting up 'Receive Path'
        packet = cnPacket()
        self.rxpath = receive_path(rx_callback, packet, options) 

        # Channel
        samples_per_packet = options.samples_per_symbol * 8 * 36
 
        if options.mode == 'default':
            print 'Operating mode : Default'
            
            mods = digital.modulation_utils.type_1_mods()
            modulator = mods[options.modulation]
            
            args = modulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / modulator(**args).bits_per_symbol()

            self.usrp_sink = uhd_transmitter(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)

            self.usrp_source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)

            options.samples_per_symbol = self.usrp_sink._sps
            
            
            #self.usrp_sink = usrp_sink(options)
            #self.usrp_source = usrp_source(options)
            self.connect(self.txpath, self.usrp_sink)
            self.connect(self.usrp_source, self.rxpath)

            
        elif options.mode == 'loopback':
            print 'Operating mode : Loopback'
      
            self.channel = channel_emulator(options,samples_per_packet)
            self.connect(self.txpath, self.channel, self.rxpath)
コード例 #27
0
ファイル: benchmark_rx.py プロジェクト: xiaov58/Coolest_Path
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.source = uhd_receiver(options.args,
                                   options.bandwidth,
                                   options.rx_freq, options.rx_gain,
                                   options.spec, options.antenna,
                                   options.verbose)


        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        self.connect(self.source, self.rxpath)
コード例 #28
0
ファイル: ssma.py プロジェクト: zhaomaomao728/gr_papyrus
    def _setup_usrp_sink2(self, options, callback):
        print "setup_usrp_sink2", self._tx_freq
        if (options.rx_freq is not None):
            self.u_src = uhd_receiver(options.args, options.bandwidth,
                                      options.rx_freq, options.rx_gain,
                                      options.spec, options.antenna,
                                      options.verbose)
            # Set up receive path
            # do this after for any adjustments to the options that may
            # occur in the sinks (specifically the UHD sink)

            # Set up receive path
            # do this after for any adjustments to the options that may
            # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, options)

        self.connect(self.u_src, self.rxpath)
コード例 #29
0
ファイル: ssma.py プロジェクト: jbruno/gr_papyrus
    def _setup_usrp_sink2(self,options,callback):
      print "setup_usrp_sink2",self._tx_freq
      if(options.rx_freq is not None):
		self.u_src = uhd_receiver(options.args,
                         options.bandwidth,
                         options.rx_freq, options.rx_gain,
                         options.spec, options.antenna,
                         options.verbose)
		# Set up receive path
		# do this after for any adjustments to the options that may
		# occur in the sinks (specifically the UHD sink)

      # Set up receive path
      # do this after for any adjustments to the options that may
      # occur in the sinks (specifically the UHD sink)
      self.rxpath = receive_path(callback, options)

      self.connect(self.u_src, self.rxpath)
コード例 #30
0
    def __init__(self, callback, fwd_callback, options):
        gr.top_block.__init__(self)

        self.source = uhd_receiver(options.args, options.bandwidth,
                                   options.rx_freq, options.rx_gain,
                                   options.spec, options.antenna,
                                   options.verbose)

        self.sink = uhd_transmitter(options.args, options.bandwidth,
                                    options.tx_freq, options.tx_gain,
                                    options.spec, options.antenna,
                                    options.verbose)

        self.rxpath = receive_path(callback, fwd_callback, options)
        self.connect(self.source, self.rxpath)

        self.txpath = transmit_path(options)
        self.connect(self.txpath, self.sink)
コード例 #31
0
    def rx_callback(ok, payload):
        global n_rcvd, n_right, flag

        (pktno, ) = struct.unpack('!H', payload[0:2])
        data = payload[2:]
        #Check if packet is not a sensing packet and if so, send it to sock
        #Also check if the packet has already been delivered
        if pktno <= 1000:

            n_rcvd += 1
            if ok:
                n_right += 1
                for i in range(0, len(packets_delivered)):
                    if packets_delivered[i] == pktno:
                        not_delivered = False
                if options.server and not_delivered:
                    packets_delivered.append(pktno)
                    sock.sendall(data)
                not_delivered = True

#Check if pakcet is a sensing packet and jump freq accordingly
        if pktno > 1000 and flag == 0:
            if ok:
                flag = 1
                new_freq = int(float(data))
                new = new_freq / 1.0
                print "About to change freq"
                #Sleep to keep sync
                time.sleep(0.5)

                options.rx_freq = new
                source = uhd_receiver(options.args, symbol_rate2,
                                      options.samples_per_symbol,
                                      options.rx_freq, options.lo_offset,
                                      options.rx_gain, options.spec,
                                      options.antenna, options.clock_source,
                                      options.verbose)
                rxpath = receive_path(demodulator2, rx_callback, options)
        #Reset flag if sensing packet burst is over
        if pktno < 1000 and flag == 1:
            flag = 0

        print "ok = %5s  pktno = %4d  n_rcvd = %4d  n_right = %4d frequency = %s" % (
            ok, pktno, n_rcvd, n_right, options.rx_freq)
コード例 #32
0
ファイル: rx_pingpong.py プロジェクト: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        data_capsule = ( (+0+0j), (+0+0j), (+0+0j), (+0+0j), (+0+0j),
                         (+1+1j), (+1+1j), (+1+1j), (+1+1j), (+1+1j) )

        symbol_rate = 500000

        self.source = uhd_receiver(options.args, symbol_rate,
                                   2,
                                   options.rx_freq, 30,
                                   options.spec, "RX2",
                                   options.verbose)

        self.tx = uhd_transmitter(options.args, symbol_rate,
                                    2,
                                    options.tx_freq, 30,
                                    options.spec, "TX/RX", 
                                    options.verbose)

        options.samples_per_symbol = self.source._sps

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
 
        self.serve = gr.vector_source_c(data_capsule)
        
        #self.correlator = correlator_cc.correlator_cc()

        #self.sink = gr.vector_sink_c()
        #self.file_sink = gr.file_sink(gr.sizeof_gr_complex, "out")

        self.server = correlator_cc.go_start_cc()
        self.inserter = correlator_cc.preamble_insert_cc()
        self.correlator = correlator_cc.correlator_cc()
      
        self.connect(self.source, self.correlator)
        self.connect(self.serve, (self.server,0))
        self.connect(self.correlator, (self.server,1))
       
        self.connect(self.server, self.inserter)
        self.connect(self.inserter, self.tx)
コード例 #33
0
    def rx_callback(ok, payload):
        global n_rcvd, n_right, flag

        (pktno,) = struct.unpack('!H', payload[0:2])
	data = payload[2:]
	#Check if packet is not a sensing packet and if so, send it to sock
	#Also check if the packet has already been delivered
	if pktno <= 1000:
        	
        	n_rcvd += 1
		if ok:
            		n_right += 1
			for i in range(0, len(packets_delivered)):
				if packets_delivered[i] == pktno:
					not_delivered = False
            		if options.server and not_delivered:
				packets_delivered.append(pktno)
                		sock.sendall(data)
			not_delivered = True
	#Check if pakcet is a sensing packet and jump freq accordingly
        if pktno > 1000 and flag == 0:
		if ok :
            		flag = 1
	    		new_freq =int(float(data))
	    		new = new_freq/1.0
	    		print "About to change freq"
	    		#Sleep to keep sync
	    		time.sleep(0.5)            

            		options.rx_freq = new
            		source = uhd_receiver(options.args, symbol_rate2,
                                       options.samples_per_symbol, options.rx_freq, 
                                       options.lo_offset, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.clock_source, options.verbose)
            		rxpath = receive_path(demodulator2, rx_callback, options)
        #Reset flag if sensing packet burst is over
	if pktno <1000 and flag == 1:
		flag = 0
        
        print "ok = %5s  pktno = %4d  n_rcvd = %4d  n_right = %4d frequency = %s" % (
            ok, pktno, n_rcvd, n_right, options.rx_freq)
コード例 #34
0
    def __init__(self, demod, options):

        gr.top_block.__init__(self, "rx_mpsk")

        self._demodulator_class = demod

        # Get demod_kwargs
        demod_kwargs = self._demodulator_class.extract_kwargs_from_options(
            options)

        # demodulator
        self._demodulator = self._demodulator_class(**demod_kwargs)

        if (options.rx_freq is not None):
            symbol_rate = options.bitrate / self._demodulator.bits_per_symbol()
            self._source = uhd_receiver(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
            options.samples_per_symbol = self._source._sps

        elif (options.from_file is not None):
            self._source = blocks.file_source(gr.sizeof_gr_complex,
                                              options.from_file)
        else:
            self._source = blocks.null_source(gr.sizeof_gr_complex)

        # Create the BERT receiver
        self._receiver = bert_receiver(options.bitrate,
                                       self._demodulator._constellation,
                                       options.samples_per_symbol,
                                       options.differential,
                                       options.excess_bw,
                                       gray_coded=True,
                                       freq_bw=options.freq_bw,
                                       timing_bw=options.timing_bw,
                                       phase_bw=options.phase_bw,
                                       verbose=options.verbose,
                                       log=options.log)

        self.connect(self._source, self._receiver)
コード例 #35
0
    def __init__(self, callback, fwd_callback, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args,
                                       options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
        elif(options.from_file is not None):
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(callback, fwd_callback, options)

        self.connect(self.source, self.rxpath)
コード例 #36
0
    def __init__(self, callback, fwd_callback, options):
    #def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.tx_freq is not None):
            self.sink = uhd_transmitter(options.args,
                                        options.bandwidth,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)

	if(options.rx_freq is not None):
            self.source = uhd_receiver(options.args,
                                       options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)

        elif(options.to_file is not None):
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = gr.null_sink(gr.sizeof_gr_complex)

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        print "flow:: ", options.flow

        # only for bidirectional flows: source in the reverse direction needs to 
        # start the ofdm_sink first to allow the socket connections working fine.. 
        if (options.flow == 1):
            self.rxpath = receive_path(callback, fwd_callback, options)
            self.connect(self.source, self.rxpath)

            self.txpath = transmit_path(options)
            self.connect(self.txpath, self.sink)
        else:
            self.txpath = transmit_path(options)
            self.connect(self.txpath, self.sink)

            self.rxpath = receive_path(callback, fwd_callback, options)
            self.connect(self.source, self.rxpath)
コード例 #37
0
ファイル: TxRxLayer1.py プロジェクト: vagonbar/GNUnetwork
    def __init__(self, demodulator, options, q_rx):
        '''Constructor.
        
        @param demodulator:
        @param options:
        @param q_rx:
        '''
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / \
                demodulator(**args).bits_per_symbol()

            self.source = uhd_receiver(options.args, symbol_rate,
                options.samples_per_symbol,
                options.rx_freq, options.rx_gain,
                options.spec, options.antenna,
                options.verbose)
            options.samples_per_symbol = self.source._sps

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % \
                (options.from_file)))
            self.source = gr.file_source(gr.sizeof_gr_complex, \
                options.from_file)
        else:
            sys.stderr.write( \
                "No source defined, pulling samples from null source.\n\n")
            self.source = gr.null_source(gr.sizeof_gr_complex)
        self.q_rx =q_rx
        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        if options.version == '6':
            self.rxpath = rp36(demodulator, self.rx_callback, options) 
        if options.version == '7':
            self.rxpath = rp37(demodulator, self.rx_callback, options) 
            
        self.connect(self.source, self.rxpath)
コード例 #38
0
    def __init__(self, demod, options):

	gr.top_block.__init__(self, "rx_mpsk")

        self._demodulator_class = demod

        # Get demod_kwargs
        demod_kwargs = self._demodulator_class.extract_kwargs_from_options(options)
        
        # demodulator
	self._demodulator = self._demodulator_class(**demod_kwargs)

        if(options.rx_freq is not None):
            symbol_rate = options.bitrate / self._demodulator.bits_per_symbol()
            self._source = uhd_receiver(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.spec,
                                        options.antenna, options.verbose)
            options.samples_per_symbol = self._source._sps

        elif(options.from_file is not None):
            self._source = blocks.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            self._source = blocks.null_source(gr.sizeof_gr_complex)

        # Create the BERT receiver
        self._receiver = bert_receiver(options.bitrate,
                                       self._demodulator._constellation, 
                                       options.samples_per_symbol,
                                       options.differential, 
                                       options.excess_bw, 
                                       gray_coded=True,
                                       freq_bw=options.freq_bw,
                                       timing_bw=options.timing_bw,
                                       phase_bw=options.phase_bw,
                                       verbose=options.verbose,
                                       log=options.log)
        
        self.connect(self._source, self._receiver)
コード例 #39
0
ファイル: tx_pingpong.py プロジェクト: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        # some arbitrary data
        data_capsule = ( (+1+1j), (+1+1j), (-1-1j), (-1-1j), (+1+1j),
                         (-1+1j), (-1+1j), (+1-1j), (+1-1j), (-1-1j) )


        # Work-around to get the modulation's bits_per_symbol
        symbol_rate = 500000

        self.sink = uhd_transmitter(options.args, symbol_rate,
                                    2,
                                    options.tx_freq, 30,
                                    options.spec, "TX/RX",
                                    options.verbose)

        self.rx = uhd_receiver(options.args, symbol_rate,
                               2, 
                               options.rx_freq, 30, 
                               options.spec, "RX2",
                               options.verbose)

        options.samples_per_symbol = self.sink._sps

        self.serve = gr.vector_source_c(data_capsule)
        #self.inserter = correlator_cc.preamble_insert_cc()
        #self.connect(self.source, self.inserter)
        #self.connect(self.inserter, self.sink)

        self.server = correlator_cc.go_start_cc()
        self.inserter = correlator_cc.preamble_insert_cc()
        self.correlator = correlator_cc.correlator_cc()

        self.connect(self.rx, self.correlator)
        self.connect(self.serve, (self.server,0))
        self.connect(self.correlator, (self.server,1))
        self.connect(self.server, self.inserter)
        self.connect(self.inserter, self.sink)
コード例 #40
0
    def __init__(self, callback, fwd_callback, options):
        #def __init__(self, options):
        gr.top_block.__init__(self)

        if (options.tx_freq is not None):
            self.sink = uhd_transmitter(options.args, options.bandwidth,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)

        if (options.rx_freq is not None):
            self.source = uhd_receiver(options.args, options.bandwidth,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)

        elif (options.to_file is not None):
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            self.sink = gr.null_sink(gr.sizeof_gr_complex)

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        print "flow:: ", options.flow

        # only for bidirectional flows: source in the reverse direction needs to
        # start the ofdm_sink first to allow the socket connections working fine..
        if (options.flow == 1):
            self.rxpath = receive_path(callback, fwd_callback, options)
            self.connect(self.source, self.rxpath)

            self.txpath = transmit_path(options)
            self.connect(self.txpath, self.sink)
        else:
            self.txpath = transmit_path(options)
            self.connect(self.txpath, self.sink)

            self.rxpath = receive_path(callback, fwd_callback, options)
            self.connect(self.source, self.rxpath)
コード例 #41
0
    def __init__(self, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()
            ask_sample_rate = symbol_rate*options.samples_per_symbol

            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
            options.samples_per_symbol = self.source._sps
            
            self.source.u.set_center_freq(uhd.tune_request(options.rx_freq, ask_sample_rate*2), 0)
            print 'In locking '
            while (self.source.u.get_sensor("lo_locked").to_bool() == False):
                print '.'
        
            print 'Locked'

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.rxpath = receive_path(demodulator, rx_callback, options) 

        self.connect(self.source, self.rxpath)
        self.connect(self.source, gr.file_sink(gr.sizeof_gr_complex, "benchmark_sensing.dat"))
        
        self.timer = threading.Timer(1, self.start_streaming)
コード例 #42
0
 def __init__(self, demod_class, rx_callback, options):
     '''
     See below for what options should hold
     '''
     gr.hier_block2.__init__(
         self,
         "usrp_receive_path",
         gr.io_signature(0, 0, 0),  # Input signature
         gr.io_signature(0, 0, 0))  # Output signature
     rx_path = receive_path.receive_path(demod_class, rx_callback, options)
     for attr in dir(rx_path):  #forward the methods
         if not attr.startswith('_') and not hasattr(self, attr):
             setattr(self, attr, getattr(rx_path, attr))
     #setup usrp
     args = demod_class.extract_kwargs_from_options(options)
     symbol_rate = options.bitrate / demod_class(**args).bits_per_symbol()
     self.source = uhd_receiver(options.args, symbol_rate,
                                options.samples_per_symbol, options.rx_freq,
                                options.rx_gain, options.spec,
                                options.antenna, options.verbose)
     #connect
     self.connect(self.source, rx_path)
コード例 #43
0
    def __init__(self, options, rx_callback):
        gr.top_block.__init__(self)

        if options.infile is not None:
            self.chan_num = options.channel
            u = gr.file_source(gr.sizeof_gr_complex, options.infile)
        elif (options.rx_freq) is not None or (options.channel is not None):
            if options.channel is not None:
                self.chan_num = options.channel
                options.rx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[
                    self.chan_num]

            u = uhd_receiver(options.rx_args, options.bandwidth,
                             options.rx_freq, options.rx_gain, options.spec,
                             options.antenna, options.verbose,
                             options.external)
        else:
            sys.stderr.write("--freq or --infile must be specified\n")
            raise SystemExit

        self.samples_per_symbol = 2
        self.data_rate = options.bandwidth / self.samples_per_symbol

        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(
            self,
            callback=rx_callback,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            channel=self.chan_num,
            threshold=options.threshold,
            log=options.log)

        self.src = u
        #self.squelch = gr.pwr_squelch_cc(-65, gate=True)
        self.connect(
            self.src,
            #       self.squelch,
            self.packet_receiver)
コード例 #44
0
    def __init__(self, options, rx_callback):
        gr.top_block.__init__(self)

        if options.infile is not None:
            self.chan_num = options.channel
            u = gr.file_source(gr.sizeof_gr_complex, options.infile)
        elif (options.rx_freq) is not None or (options.channel is not None):
            if options.channel is not None:
              self.chan_num = options.channel
              options.rx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num]

            u = uhd_receiver(options.rx_args,
                             options.bandwidth,
                             options.rx_freq, options.rx_gain,
                             options.spec, options.antenna,
                             options.verbose, options.external)
        else:
            sys.stderr.write("--freq or --infile must be specified\n")
            raise SystemExit

        self.samples_per_symbol = 2
        self.data_rate = options.bandwidth / self.samples_per_symbol

        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self,
                                callback=rx_callback,
                                sps=self.samples_per_symbol,
                                symbol_rate=self.data_rate,
                                channel=self.chan_num,
                                threshold=options.threshold,
                                log=options.log)

        self.src = u
        #self.squelch = gr.pwr_squelch_cc(-65, gate=True)
        self.connect(self.src,
         #       self.squelch,
                self.packet_receiver)
コード例 #45
0
ファイル: digital_bert_rx.py プロジェクト: zitouni/gnuradio
    def __init__(self, demod, options):

        gr.top_block.__init__(self, "rx_mpsk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("BER Measurement")
        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._demodulator_class = demod

        # Get demod_kwargs
        demod_kwargs = self._demodulator_class.extract_kwargs_from_options(
            options)

        # demodulator
        self._demodulator = self._demodulator_class(**demod_kwargs)

        if (options.rx_freq is not None):
            symbol_rate = options.bitrate / self._demodulator.bits_per_symbol()
            self._source = uhd_receiver(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.rx_freq, options.rx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
            options.samples_per_symbol = self._source._sps

        elif (options.from_file is not None):
            self._source = blocks.file_source(gr.sizeof_gr_complex,
                                              options.from_file)
        else:
            self._source = blocks.null_source(gr.sizeof_gr_complex)

    #Create GUI to see symbols constellation
        self.qtgui_const_sink = qtgui.const_sink_c(
            400,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink.set_update_time(0.1)
        self.qtgui_const_sink.set_y_axis(-2, 2)
        self.qtgui_const_sink.set_x_axis(-2, 2)
        self.qtgui_const_sink.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                               qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                               "")
        self.qtgui_const_sink.enable_autoscale(False)
        self.qtgui_const_sink.enable_grid(False)
        self.qtgui_const_sink.enable_axis_labels(True)

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

        self._qtgui_const_sink_win = sip.wrapinstance(
            self.qtgui_const_sink.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_win)

        #=======================================================================
        # self.connect(self._source, self.qtgui_const_sink)
        #=======================================================================

        # Create the BERT receiver
        self._receiver = bert_receiver(self.qtgui_const_sink,
                                       options.bitrate,
                                       self._demodulator._constellation,
                                       options.samples_per_symbol,
                                       options.differential,
                                       options.excess_bw,
                                       gray_coded=True,
                                       freq_bw=options.freq_bw,
                                       timing_bw=options.timing_bw,
                                       phase_bw=options.phase_bw,
                                       verbose=options.verbose,
                                       log=options.log)

        self.connect(self._source, self._receiver)
コード例 #46
0
ファイル: ofdm_rx.py プロジェクト: UpYou/ofdm
  def __init__(self, options):
    gr.top_block.__init__(self)

    if options.rx_freq is not None:
      u = uhd_receiver(options.args,
                       options.bandwidth,
                       options.rx_freq, options.rx_gain,
                       options.spec, options.antenna,
                       options.verbose)
    elif options.infile is not None:
      u = gr.file_source(gr.sizeof_gr_complex, options.infile)
    else:
      import sys
      sys.stderr.write("--freq or --infile must be specified\n")
      raise SystemExit

    self.scope = None

    if options.outfile is not None:
      rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile)
    else:
      rx = ofdm_rxtx.RX(options)
      data_tones = rx.params.data_tones
      if options.rxdata is not None:
        if options.rxdata == '.':
          import scope
          # scope it out
          rxs = gr.vector_to_stream(gr.sizeof_gr_complex, data_tones)
          self.connect(rx, rxs)
          self.scope = scope.scope(self, rxs, 'Frame SNR', isComplex=True)
        else:
          if options.char > 0:
            # rail and scale
            self.connect(rx,
                         gr.vector_to_stream(gr.sizeof_float, data_tones * 2),
                         gr.multiply_const_ff(128.0 * (2**0.5)/ options.char),
                         gr.rail_ff(-128.0, 127.0),
                         gr.float_to_char(),
                         gr.file_sink(gr.sizeof_char, options.rxdata))
          else:
            self.connect(rx, gr.file_sink(data_tones * gr.sizeof_gr_complex, options.rxdata))

      if options.snrdata is not None:
        # select one of the snr modes
        snr = ofdm_rxtx.SNR(rx.params.data_tones, options.size, mode=options.snrmode)
        if options.char > 0:
          # NOTE: we use repeat, assuming the file is long enough or properly aligned
          data = gr.stream_to_vector(gr.sizeof_float, data_tones * 2)
          self.connect(gr.file_source(gr.sizeof_char, options.txdata, repeat=True),
                      gr.char_to_float(),
                      gr.multiply_const_ff(options.char * (2**-0.5) / 128.0),
                      data)
        else:
          data = ofdm_rxtx.make_data(rx.params.data_tones, options.size, options.txdata)
        self.connect(rx, (snr,0))
        self.connect(data, (snr,1))
        if options.snrdata == '-':
          # print it out
          msgq = gr.msg_queue(16)
          self.connect(snr, gr.message_sink(gr.sizeof_float, msgq, True))
          self.watcher = ofdm_rxtx.queue_watcher(msgq)
        elif options.snrdata == '.':
          import scope
          # scope it out
          self.scope = scope.scope(self, snr, 'Frame SNR')
        else:
          self.connect(snr, gr.file_sink(gr.sizeof_float, options.snrdata))
      else:
        pass
        #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this?

    self.connect(u, rx)
コード例 #47
0
ファイル: benchmark_tx3.py プロジェクト: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        options = copy.copy(options)
        symbol_rate = 2500000

 
 
        print "%f" % (options.tx_freq-1.25e6)
        #print "==========================================\n"
        #print "Samp per sym = %d\n" % options.samples_per_symbol
        #print "==========================================\n"

        self.source = uhd_receiver(options.args, symbol_rate, 
                                   1, #options.samples_per_symbol,
                                   options.tx_freq-1.25e6, 30,
                                   options.spec, options.antenna,
                                   options.verbose)

        low_pass_taps = [
	    -0.0401,
	    0.0663,
	    0.0468,
	    -0.0235,
	    -0.0222,
	    0.0572,
	    0.0299,
	    -0.1001,
	    -0.0294,
	    0.3166,
	    0.5302,
	    0.3166,
	    -0.0294,
	    -0.1001,
	    0.0299,
	    0.0572,
	    -0.0222,
	    -0.0235,
	    0.0468,
	    0.0663,
	    -0.0401]

	high_pass_taps = [
	    -0.0389,
	    -0.0026,
	    0.0302,
	    0.0181,
	    -0.0357,
	    -0.0394,
	    0.0450,
	    0.0923,
	    -0.0472,
	    -0.3119,
	    0.5512,
	    -0.3119,
	    -0.0472,
	    0.0923,
	    0.0450,
	    -0.0394,
	    -0.0357,
	    0.0181,
	    0.0302,
	    -0.0026,
	    -0.0389]

        # Carrier Sensing Blocks
        alpha = 0.5
        thresh = 30   # in dB, will have to adjust
        self.probe_lp = gr.probe_avg_mag_sqrd_c(thresh,alpha)
        self.probe_hp = gr.probe_avg_mag_sqrd_c(thresh,alpha)

        self.lp = gr.fft_filter_ccc(32, low_pass_taps)
        self.hp = gr.fft_filter_ccc(32, high_pass_taps)

        self.connect(self.source, self.lp)
        self.connect(self.lp, self.probe_lp)

        self.connect(self.source, self.hp)
        self.connect(self.hp, self.probe_hp)
コード例 #48
0
        gr.top_block.__init__(self) # Parent constructor called
=======
        gr.top_block.__init__(self) # create gnuradio contra
>>>>>>> 8d49faa84f59bbacfa1e96f9d30a844fba01f641

	# Setup options if not chosen on command-line
        if(options.rx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = demodulator.extract_kwargs_from_options(options)
	    print args
            symbol_rate = options.bitrate / demodulator(**args).bits_per_symbol()

	    # Set parameters for receiver, class found in uhd_interface.py
            self.source = uhd_receiver(options.args, symbol_rate,
                                       options.samples_per_symbol,
                                       options.rx_freq, options.rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)
            options.samples_per_symbol = self.source._sps
	# If transmission sources is a file
        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
	# Transmission source
	else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
コード例 #49
0
    def __init__(self, modulator, demodulator, rx_callback, options):
        gr.top_block.__init__(self)

        sense_symbol_rate=2500000
        sense_samples_per_symbol=2
        sense_rx_freq=2500000000
        sense_rx_gain=20
        options.chbw_factor=1
   
        global bandchoose


 
        #args = demodulator.extract_kwargs_from_options(options)
        self.sensesource=uhd_receiver(options.args, sense_symbol_rate,
                                       sense_samples_per_symbol,
                                       sense_rx_freq, sense_rx_gain,
                                       options.spec, options.antenna,
                                       options.verbose)

        if(options.tx_freq is not None):
            # Work-around to get the modulation's bits_per_symbol
            args = modulator.extract_kwargs_from_options(options)
            symbol_rate = options.bitrate / modulator(**args).bits_per_symbol()
	    
            fa = samp_rate/4 #1000000

            self.sink = uhd_transmitter(options.args, symbol_rate,
                                        options.samples_per_symbol,
                                        options.tx_freq, options.tx_gain,
                                        options.spec, options.antenna,
                                        options.verbose)
            options.samples_per_symbol = self.sink._sps
            
        elif(options.to_file is not None):
            sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file)))
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            sys.stderr.write("No sink defined, dumping samples to null sink.\n\n")
            self.sink = gr.null_sink(gr.sizeof_gr_complex)


        self.txgate = gr.copy(gr.sizeof_gr_complex)
        self.sensegate = gr.copy(gr.sizeof_gr_complex)
        #self.msgq             = gr.msg_queue()

        # do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)


	# do sense
        self.sensepath = sensing_path(options)

        self.tx_enabled = True
	self.sense_flag=False

        self.connect(self.sensesource, self.sensepath)

	# do this after for any adjustments to the options that may
        # occur in the sinks (specifically the UHD sink)
        self.txpath1 = transmit_path(modulator, options)
	self.txpath2 = transmit_path(modulator, options)

	#self.connect(self.txpath, self.sink)

	# Define the math operator blocks
	

	# Generate exp(jw1t) and exp(-jw1t)
	self.gr_multiply_xx_0 = gr.multiply_vff(1)
	self.gr_float_to_complex_0_0 = gr.float_to_complex(1)
	self.gr_float_to_complex_0 = gr.float_to_complex(1)
	self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, -1)
	self.analog_sig_source_x_0_0 = gr.sig_source_f(samp_rate, gr.GR_SIN_WAVE, fa, 1, 0)
	self.analog_sig_source_x_0 = gr.sig_source_f(samp_rate, gr.GR_COS_WAVE, fa, 1, 0)


	# Combine signal from two subbands
	self.gr_multiply_xx_1 = gr.multiply_vcc(1)
	self.gr_multiply_xx_2 = gr.multiply_vcc(1)
	self.gr_c2f_1 = gr.complex_to_float(1)
	self.gr_c2f_2 = gr.complex_to_float(1)
	self.gr_add_xx_re = gr.add_vff(1)
	self.gr_add_xx_im = gr.add_vff(1)
	self.gr_f2c = gr.float_to_complex(1)
	
 	self.gr_null_source_0 = gr.null_source(gr.sizeof_gr_complex*1)

	# output from gr_float_to_complex_0_0 is exp(-jw1t)
	# output from gr_float_to_complex_0 is exp(jw1t)
	self.connect((self.gr_multiply_xx_0, 0), (self.gr_float_to_complex_0_0, 1))
	self.connect((self.analog_sig_source_x_0, 0), (self.gr_float_to_complex_0_0, 0))
	self.connect((self.analog_sig_source_x_0_0, 0), (self.gr_float_to_complex_0, 1))
	self.connect((self.analog_sig_source_x_0, 0), (self.gr_float_to_complex_0, 0))
	self.connect((self.analog_sig_source_x_0_0, 0), (self.gr_multiply_xx_0, 0))
	self.connect((self.const_source_x_0, 0), (self.gr_multiply_xx_0, 1)) 

	# txpath1 * exp(-jw1t)
	#self.connect(self.txpath1, (self.gr_multiply_xx_1, 0))
	self.connect((self.gr_float_to_complex_0_0, 0), (self.gr_multiply_xx_1, 1))
	# txpath2 * exp(jw1t)
	#self.connect(self.txpath2, (self.gr_multiply_xx_2, 0))
	
	self.connect((self.gr_float_to_complex_0, 0), (self.gr_multiply_xx_2, 1))
	
	if bandchoose == 0:
		self.connect(self.txpath1, (self.gr_multiply_xx_1, 0))
		self.connect(self.gr_null_source_0 , (self.gr_multiply_xx_2, 0))
	elif bandchoose == 1:
		self.connect(self.gr_null_source_0 , (self.gr_multiply_xx_1, 0))
		self.connect(self.txpath2, (self.gr_multiply_xx_2, 0))
	else:
		self.connect(self.txpath1, (self.gr_multiply_xx_1, 0))
		self.connect(self.txpath2, (self.gr_multiply_xx_2, 0))

	self.connect((self.gr_multiply_xx_1, 0), self.gr_c2f_1)
	self.connect((self.gr_multiply_xx_2, 0), self.gr_c2f_2)

	self.connect((self.gr_c2f_1,0), (self.gr_add_xx_re,0))
	self.connect((self.gr_c2f_2,0), (self.gr_add_xx_re,1))

	self.connect((self.gr_c2f_1,1), (self.gr_add_xx_im,0))
	self.connect((self.gr_c2f_2,1), (self.gr_add_xx_im,1))

	self.connect(self.gr_add_xx_re, (self.gr_f2c,0))
	self.connect(self.gr_add_xx_im, (self.gr_f2c,1))
        self.connect(self.gr_f2c, self.sink)
コード例 #50
0
ファイル: rx.py プロジェクト: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        # Source block
        symbol_rate = 500000
        self.source = uhd_receiver(options.args, symbol_rate,
                                   2,
                                   options.rx_freq, 30,
                                   #options.spec, "RX2",
                                   options.spec, "TX/RX",
                                   1) #options.verbose)
        options.samples_per_symbol = self.source._sps


        RX_output_file = "RX_output_test_file"
	_RX_output_file = 'RX_output_test_file'
        #RX_output_file = "Ding_Dong2.wma"
	#_RX_output_file = 'Ding_Dong2.wma'


        RX_file_sink = gr.file_sink(gr.sizeof_char, RX_output_file)
	RX_output_filesize = os.stat(_RX_output_file).st_size
  
        #print RX_output_filesize



        self.filesink = gr.file_sink(1, "output_file")


	# Correlator block
        self.correlator = correlator_cc.correlator_cc()

	# Despreader block
	self.despreader = spreader.despreader_cb()
  
        # RS Decoder block
	self.decoder = rscoding_bb.decode_bb()

        # CRC RX Block
        self.crcrx = crc.crcrx()

	# Print block
	self.printer = print_bb.print_bb()

	# NULL sink block
        self.nullsink = gr.null_sink(1)
 
        # RRC filter
        #nfilts = 32 
        #ntaps = nfilts * 11 * int(options.samples_per_symbol)
        #self.rrc_taps = gr.firdes.root_raised_cosine(
            #1.0, # gain
            #1000000, # sampling rate based on 32 fliters in resampler
            #symbol_rate,    # symbol rate
            #1.0,    # excess bandwidth or roll-off factor
            #ntaps)
        #self.rrc_filter = gr.pfb_arb_resampler_ccf(options.samples_per_symbol, 
        #                                           self.rrc_taps)


        # Design filter to get actual channel we want
        sw_decim = 1
        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
                                          #sw_decim * self.samples_per_symbol(), # sampling rate
                                          #1000000, # sampling rate
                                          2,
                                          #self._chbw_factor,    # midpoint of trans. band
                                          1,    # midpoint of trans. band
                                          0.5,                  # width of trans. band
                                          gr.firdes.WIN_HANN)   # filter type
        self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)


	# Connect the blocks
        #self.connect(self.source, self.correlator)
        #self.connect(self.source, self.rrc_filter)
        #self.connect(self.rrc_filter, self.correlator)

        # connect block input to channel filter
	self.connect(self.source, self.channel_filter)
        self.connect(self.channel_filter, self.correlator)


        #self.connect(self.source, self.correlator)
        self.connect(self.correlator, self.despreader)
        self.connect(self.despreader, self.decoder)
        self.connect(self.decoder, self.crcrx)
        #self.connect(self.decoder, self.printer)
        #self.connect(self.printer, self.crcrx)
        #self.connect(self.despreader, self.printer)
        #self.connect(self.printer, self.nullsink)
        #self.connect(self.printer, self.filesink)
        #self.connect(self.crcrx, self.filesink)
        self.connect(self.crcrx, RX_file_sink)
コード例 #51
0
ファイル: bot1_rx.py プロジェクト: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
	    symbol_rate = 500000
	    self.source = uhd_receiver(options.args, symbol_rate,
				       2,
				       options.rx_freq, 30,
				       #options.spec, "RX2",
				       options.spec, "TX/RX",
				       1) #options.verbose)
	    options.samples_per_symbol = self.source._sps

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
	# Correlator block
        self.correlator = correlator_cc.correlator_cc()

	# Despreader block
	self.despreader = spreader.despreader_cb()
  
        # RS Decoder block
	self.decoder = rscoding_bb.decode_bb()

        # CRC RX Block
        self.crcrx = crc.crcrx()

	# Packetizer receiver
	self.packetrx = packetizer.packet_sink()

	# Print block
	self.printer = print_bb.print_bb()

	# NULL sink block
        self.nullsink = gr.null_sink(1)
 
        # RRC filter
        #nfilts = 32 
        #ntaps = nfilts * 11 * int(options.samples_per_symbol)
        #self.rrc_taps = gr.firdes.root_raised_cosine(
            #1.0, # gain
            #1000000, # sampling rate based on 32 fliters in resampler
            #symbol_rate,    # symbol rate
            #1.0,    # excess bandwidth or roll-off factor
            #ntaps)
        #self.rrc_filter = gr.pfb_arb_resampler_ccf(options.samples_per_symbol, 
        #                                           self.rrc_taps)


        # Design filter to get actual channel we want
        sw_decim = 1
        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
                                          #sw_decim * self.samples_per_symbol(), # sampling rate
                                          #1000000, # sampling rate
                                          2,
                                          #self._chbw_factor,    # midpoint of trans. band
                                          1,    # midpoint of trans. band
                                          0.5,                  # width of trans. band
                                          gr.firdes.WIN_HANN)   # filter type
        self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)


	# Connect the blocks
        #self.connect(self.source, self.correlator)
        #self.connect(self.source, self.rrc_filter)
        #self.connect(self.rrc_filter, self.correlator)

        # connect block input to channel filter
	self.connect(self.source, self.channel_filter)
        self.connect(self.channel_filter, self.correlator)


        #self.connect(self.source, self.correlator)
        self.connect(self.correlator, self.despreader)
        self.connect(self.despreader, self.decoder)
        self.connect(self.decoder, self.crcrx)
        #self.connect(self.decoder, self.printer)
        #self.connect(self.printer, self.crcrx)
        #self.connect(self.despreader, self.printer)
        #self.connect(self.printer, self.nullsink)
        #self.connect(self.printer, self.filesink)
        #self.connect(self.crcrx, self.filesink)
        self.connect(self.crcrx, self.packetrx) 
コード例 #52
0
  def __init__(self, options_tx, options_rx, callback):
    gr.top_block.__init__(self)

    self.init_pctime = 0
    self.init_hwtime = 0

    self.tx_outfile    = options_tx.tx_outfile
    self._tx_amplitude = options_tx.tx_amplitude 
    #######################################################################
    #                              USRP Config                            #
    #######################################################################
    tx_slave=False
    rx_slave=False
    if options_tx.tx_args != options_rx.rx_args:
      print "===Transceiver: enable MIMO mode, RX as slave, TX as master==="
      rx_slave=True
    if options_rx.mode == "PNC":
      rx_slave=False
      
    # lzyou: it seems that you MUST put rx before tx
    # otherwise something strange will happen (eg, not synced even the program tells you synced)
    d_rx_enable = True
    if options_rx.rx_freq is not None:
      source = uhd_receiver(options_rx.rx_args,
                            options_rx.bandwidth,
                            options_rx.rx_freq, options_rx.rx_gain,
                            options_rx.spec, options_rx.antenna,
                            options_rx.verbose, options_rx.external, rx_slave)
      #source.u.set_min_output_buffer(163840)
    elif options_rx.rx_infile is not None:
      source = blocks.file_source(gr.sizeof_gr_complex, options_rx.rx_infile)
    else:
      source = None
      d_rx_enable = False
    self.d_rx_enable = d_rx_enable
    self.source = source
    
    d_tx_enable = True
    if options_tx.tx_freq is not None:
      sink = uhd_transmitter(options_tx.tx_args,
                             options_tx.bandwidth,
                             options_tx.tx_freq, options_tx.tx_gain,
                             options_tx.spec, options_tx.antenna,
                             options_tx.verbose, options_tx.external, tx_slave)
    elif options_tx.tx_outfile is not None:
      sink = blocks.file_sink(gr.sizeof_gr_complex, options_tx.tx_outfile)
    else:
      sink = None
      d_tx_enable = False
    self.d_tx_enable = d_tx_enable
    self.sink = sink
    #######################################################################

    # FIXME: support diff (tx/rx) framebytes   
    self.framebytes = None
    #######################################################################
    #                              Tx Path                                #
    #######################################################################
    if d_tx_enable:
      self.tx = transmit_path.ofdm_transmit_path(options_tx)
      self.amp = blocks.multiply_const_cc(self._tx_amplitude)
      #self.amp.set_min_output_buffer(163840)
      self.connect(self.tx, self.amp, self.sink)
      self.framebytes = self.tx.framebytes
    #######################################################################
    
    #######################################################################
    #                              Rx Path                                #
    #######################################################################
    # log usrp raw samples
    #if options_rx.mode == 'PNC':
    #  self.connect(source, blocks.file_sink(gr.sizeof_gr_complex, '/tmp/PNCRXdiag.dat'))
    if options_rx.logfile:
      if options_rx.mode == 'PNC':
        self.connect(source, blocks.file_sink(gr.sizeof_gr_complex, '/tmp/PNCRXdiag.dat'))
      else:
        assert(options_rx.node != None)

      if options_rx.node == 'A':
        self.connect(source, blocks.file_sink(gr.sizeof_gr_complex, '/tmp/NodeARXdiag.dat'))
      elif options_rx.node == 'B':
        self.connect(source, blocks.file_sink(gr.sizeof_gr_complex, '/tmp/NodeBRXdiag.dat'))

    # setup receive_path
    if d_rx_enable:
      if options_rx.rx_outfile is not None:
        self.rx = blocks.file_sink(gr.sizeof_gr_complex, options_rx.rx_outfile)
        self.connect(self.source, self.rx)
        return
      
      self.rx = receive_path.ofdm_receive_path(options_rx, callback)
      #if self.framebytes is not None:
      #  assert(self.framebytes == self.rx.framebytes)
      self.framebytes = self.rx.framebytes
      self.connect(self.source, self.rx)
    else:
      self.rx = None

    #######################################################################
    if options_rx.profile:
      from gnuradio.ctrlport import monitor
      self.ctrlport_monitor = monitor()
      self.ctrlport_monitor_performance = monitor("gr-perf-monitorx")
コード例 #53
0
ファイル: ofdm_rx.py プロジェクト: ljxangus/ofdm
    def __init__(self, options):
        gr.top_block.__init__(self)

        if options.rx_freq is not None:
            u = uhd_receiver(options.args, options.bandwidth, options.rx_freq,
                             options.rx_gain, options.spec, options.antenna,
                             options.verbose)
        elif options.infile is not None:
            u = gr.file_source(gr.sizeof_gr_complex, options.infile)
        else:
            import sys
            sys.stderr.write("--freq or --infile must be specified\n")
            raise SystemExit

        self.scope = None

        if options.outfile is not None:
            rx = gr.file_sink(gr.sizeof_gr_complex, options.outfile)
        else:
            rx = ofdm_rxtx.RX(options)
            data_tones = rx.params.data_tones
            if options.rxdata is not None:
                if options.rxdata == '.':
                    import scope
                    # scope it out
                    rxs = gr.vector_to_stream(gr.sizeof_gr_complex, data_tones)
                    self.connect(rx, rxs)
                    self.scope = scope.scope(self,
                                             rxs,
                                             'Frame SNR',
                                             isComplex=True)
                else:
                    if options.char > 0:
                        # rail and scale
                        self.connect(
                            rx,
                            gr.vector_to_stream(gr.sizeof_float,
                                                data_tones * 2),
                            gr.multiply_const_ff(128.0 * (2**0.5) /
                                                 options.char),
                            gr.rail_ff(-128.0, 127.0), gr.float_to_char(),
                            gr.file_sink(gr.sizeof_char, options.rxdata))
                    else:
                        self.connect(
                            rx,
                            gr.file_sink(data_tones * gr.sizeof_gr_complex,
                                         options.rxdata))

            if options.snrdata is not None:
                # select one of the snr modes
                snr = ofdm_rxtx.SNR(rx.params.data_tones,
                                    options.size,
                                    mode=options.snrmode)
                if options.char > 0:
                    # NOTE: we use repeat, assuming the file is long enough or properly aligned
                    data = gr.stream_to_vector(gr.sizeof_float, data_tones * 2)
                    self.connect(
                        gr.file_source(gr.sizeof_char,
                                       options.txdata,
                                       repeat=True), gr.char_to_float(),
                        gr.multiply_const_ff(options.char * (2**-0.5) / 128.0),
                        data)
                else:
                    data = ofdm_rxtx.make_data(rx.params.data_tones,
                                               options.size, options.txdata)
                self.connect(rx, (snr, 0))
                self.connect(data, (snr, 1))
                if options.snrdata == '-':
                    # print it out
                    msgq = gr.msg_queue(16)
                    self.connect(snr,
                                 gr.message_sink(gr.sizeof_float, msgq, True))
                    self.watcher = ofdm_rxtx.queue_watcher(msgq)
                elif options.snrdata == '.':
                    import scope
                    # scope it out
                    self.scope = scope.scope(self, snr, 'Frame SNR')
                else:
                    self.connect(
                        snr, gr.file_sink(gr.sizeof_float, options.snrdata))
            else:
                pass
                #self.connect(rx, gr.null_sink(symbol_size)) # XXX do we still need this?

        self.connect(u, rx)