Пример #1
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.samp_rate = samp_rate = 1000000

        self.source = iio.pluto_source(options.dev_ip,
                                       options.rx_freq, samp_rate,
                                       long(options.bandwidth * 2), 0xA000,
                                       True, True, True, "fast_attack", 64.0,
                                       '', True)
        """
        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)
        """
        #0x8000
        self.sink = iio.pluto_sink(options.dev_ip, options.tx_freq, samp_rate,
                                   long(options.bandwidth), 0xA000, False,
                                   10.0, '', True)
        """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)
        """
        self.txpath = transmit_path(options)
        self.rxpath = receive_path(callback, options)

        self.connect(self.txpath, self.sink)
        self.connect(self.source, self.rxpath)
Пример #2
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" )
        self.osmosdr_source_0.set_sample_rate(5e6)
        self.osmosdr_source_0.set_center_freq(2.412e9, 0)
        self.osmosdr_source_0.set_freq_corr(10, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(True, 0)
        self.osmosdr_source_0.set_gain(20, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(5e6, 0)
        
        if(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.osmosdr_source_0, self.rxpath)
Пример #3
0
    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)
Пример #4
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self.samp_rate = samp_rate = 1000000
        self.band_width = band_width = 20000000
        if (options.rx_freq is not None):
            self.source = iio.pluto_source('192.168.2.1',
                                           options.rx_freq, samp_rate,
                                           long(options.bandwidth), 0x8000,
                                           True, True, True, "slow_attack",
                                           64.0, '', True)
            #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.connect(self.source, self.rxpath)
Пример #5
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)
Пример #6
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._rx_freq = options.rx_freq  # receiver's center frequency
        self._rx_gain = options.rx_gain  # receiver's gain
        self._rx_subdev_spec = options.rx_subdev_spec  # daughterboard to use
        self._decim = options.decim  # Decimating rate for the USRP (prelim)
        self._fusb_block_size = options.fusb_block_size  # usb info for USRP
        self._fusb_nblocks = options.fusb_nblocks  # usb info for USRP
        self._which = options.which  # linklab, which USRP to use

        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self.u_src = uhd.usrp_source(
            device_addr=options.args, stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1))
        )
        print "Setting Rx Params. Fs=%e, Fc=%e, G=%f" % (self._bandwidth, self._rx_freq, self._rx_gain)
        self.u_src.set_samp_rate(self._bandwidth)
        self.u_src.set_center_freq(self._rx_freq)
        self.u_src.set_gain(self._rx_gain)

        # Set up receive path
        self.rxpath = receive_path(callback, options)

        self.connect(self.u_src, self.rxpath)
Пример #7
0
    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)
Пример #8
0
    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)
Пример #9
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain
        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to use
        self._decim              = options.decim           # Decimating rate for the USRP (prelim)
        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP

        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self._setup_usrp_source()
        ok = self.set_freq(self._rx_freq)
        if not ok:
            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._rx_freq))
            raise ValueError, eng_notation.num_to_str(self._rx_freq)
        g = self.subdev.gain_range()
        if options.show_rx_gain_range:
            print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \
                  % (g[0], g[1], g[2])
        self.set_gain(options.rx_gain)
        self.set_auto_tr(True)                 # enable Auto Transmit/Receive switching

        # Set up receive path
        self.rxpath = receive_path(callback, options)

        self.connect(self.u, self.rxpath)
Пример #10
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
        if options.rx_freq is None:
            sys.stderr.write(
                "-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        #setup usrp
        self._demod_class = demod_class
        self._setup_usrp_source(options)

        self.rx_path = receive_path.receive_path(demod_class, rx_callback,
                                                 options)
        for attr in dir(self.rx_path):  #forward the methods
            if not attr.startswith('_') and not hasattr(self, attr):
                setattr(self, attr, getattr(self.rx_path, attr))

        #connect
        self.connect(self.u, self.rx_path)
Пример #11
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        #init receive
        self._rx_freq = options.rx_freq
        self._rx_gain = options.rx_gain
        self._rx_subdev_spec = options.rx_subdev_spec
        self._decim = options.decim

        #init transmit
        self._tx_freq = options.tx_freq
        self._tx_subdev_spec = options.tx_subdev_spec
        self._interp = options.interp
        
        #init both
        self._fusb_block_size = options.fusb_block_size
        self._fusb_nblocks = options.fusb_nblocks

        #check receive
        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        #check transmit
        if self._tx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        #set up usrp source
        self._setup_usrp_source()
        #self._setup_usrp_sink()


        self.rx_path = receive_path(callback, options)
        self.connect(self.rx_u, self.rx_path)
Пример #12
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()
Пример #13
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._rx_freq = options.rx_freq  # receiver's center frequency
        self._rx_gain = options.rx_gain  # receiver's gain
        self._rx_subdev_spec = options.rx_subdev_spec  # daughterboard to use
        self._decim = options.decim  # Decimating rate for the USRP (prelim)
        self._fusb_block_size = options.fusb_block_size  # usb info for USRP
        self._fusb_nblocks = options.fusb_nblocks  # usb info for USRP
        self._which = options.which  # linklab, which USRP to use

        if self._rx_freq is None:
            sys.stderr.write(
                "-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self.u_src = uhd.usrp_source(device_addr=options.args,
                                     stream_args=uhd.stream_args(
                                         cpu_format="fc32",
                                         channels=range(1),
                                     ))
        print "Setting Rx Params. Fs=%e, Fc=%e, G=%f" % (
            self._bandwidth, self._rx_freq, self._rx_gain)
        self.u_src.set_samp_rate(self._bandwidth)
        self.u_src.set_center_freq(self._rx_freq)
        self.u_src.set_gain(self._rx_gain)

        # Set up receive path
        self.rxpath = receive_path(callback, options)

        self.connect(self.u_src, self.rxpath)
Пример #14
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain
        self._rate               = options.rate            # USRP sample rate
        self._snr                 = options.snr

        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self._setup_usrp_source()
        self.set_freq(self._rx_freq)
        g = self.u.get_gain_range()
        if options.show_rx_gain_range:
            print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \
                  % (g.start(), g.stop(), g.step())
        self.set_gain(options.rx_gain)
                
        if options.verbose:
            self._print_verbage()
        
        # Set up receive path
        self.rxpath = receive_path(callback, options)
        #self.file = gr.file_sink(gr.sizeof_gr_complex, "usrp_source.dat")

        self.connect(self.u, self.rxpath)
Пример #15
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)
Пример #16
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'))
Пример #17
0
    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)        
Пример #18
0
    def __init__(self, options):    

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

        print "USRP decimation rate", options.decim_rate

        # Create a USRP source at desired board, sample rate, frequency, and gain
        self._setup_usrp(options.which,
                         options.decim_rate,
                         options.rx_subdev_spec,
                         options.freq,
                         options.gain)

        # Create the BERT receiver
        if_rate = self._usrp.adc_rate()/options.decim_rate
        self._receiver = receive_path(if_rate,
                                      options.rate,
                                      options.excess_bw,
                                      options.costas_alpha,
                                      options.costas_beta,
                                      options.costas_max,
                                      options.mm_gain_mu,
                                      options.mm_gain_omega,
                                      options.mm_omega_limit)
        
        self.connect(self._usrp, self._receiver)
Пример #19
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)
        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
Пример #20
0
    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)
Пример #21
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
Пример #22
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()
Пример #23
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._rx_freq = options.rx_freq  # receiver's center frequency
        self._rx_gain = options.rx_gain  # receiver's gain
        self._rx_subdev_spec = options.rx_subdev_spec  # daughterboard to use
        self._decim = options.decim  # Decimating rate for the USRP (prelim)
        self._fusb_block_size = options.fusb_block_size  # usb info for USRP
        self._fusb_nblocks = options.fusb_nblocks  # usb info for USRP

        if self._rx_freq is None:
            sys.stderr.write(
                "-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP source
        self._setup_usrp_source()
        ok = self.set_freq(self._rx_freq)
        if not ok:
            print "Failed to set Rx frequency to %s" % (
                eng_notation.num_to_str(self._rx_freq))
            raise ValueError, eng_notation.num_to_str(self._rx_freq)
        g = self.subdev.gain_range()
        if options.show_rx_gain_range:
            print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g" \
                  % (g[0], g[1], g[2])
        self.set_gain(options.rx_gain)
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching

        # Set up receive path
        self.rxpath = receive_path(callback, options)

        self.connect(self.u, self.rxpath)
Пример #24
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)
Пример #25
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()
    def __init__(self, mod_class, demod_class,
                 rx_callback, options):

        gr.top_block.__init__(self)
        self.txpath = transmit_path(mod_class, options)
        self.rxpath = receive_path(demod_class, rx_callback, options)
	self.connect(self.txpath);
	self.connect(self.rxpath);
Пример #27
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if not options.channel_off:
            SNR = 10.0**(options.snr / 10.0)
            power_in_signal = abs(options.tx_amplitude)**2.0
            noise_power_in_channel = power_in_signal / SNR
            noise_voltage = math.sqrt(noise_power_in_channel / 2.0)
            print "Noise voltage: ", noise_voltage

            frequency_offset = options.frequency_offset / options.fft_length
            print "Frequency offset: ", frequency_offset

            if options.multipath_on:
                taps = [1.0, .2, 0.0, .1, .08, -.4, .12, -.2, 0, 0, 0, .3]
            else:
                taps = [1.0, 0.0]

        else:
            noise_voltage = 0.0
            frequency_offset = 0.0
            taps = [1.0, 0.0]

        symbols_per_packet = math.ceil(
            ((4 + options.size + 4) * 8) / options.occupied_tones)
        samples_per_packet = (symbols_per_packet + 2) * (options.fft_length +
                                                         options.cp_length)
        print "Symbols per Packet: ", symbols_per_packet
        print "Samples per Packet: ", samples_per_packet
        if options.discontinuous:
            stream_size = [
                100000,
                int(options.discontinuous * samples_per_packet)
            ]
        else:
            stream_size = [0, 100000]

        z = [
            0,
        ]
        self.zeros = gr.vector_source_c(z, True)
        self.txpath = transmit_path(options)

        #self.mux = gr.stream_mux(gr.sizeof_gr_complex, stream_size)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
        self.channel = gr.channel_model(noise_voltage, frequency_offset,
                                        options.clockrate_ratio, taps)
        self.rxpath = receive_path(callback, options)

        #self.connect(self.zeros, (self.mux,0))
        #self.connect(self.txpath, (self.mux,1))
        #self.connect(self.mux, self.throttle, self.channel, self.rxpath)
        #self.connect(self.mux, self.throttle, self.rxpath)
        self.connect(self.txpath, self.throttle, self.channel, self.rxpath)

        if options.log:
            self.connect(self.txpath,
                         gr.file_sink(gr.sizeof_gr_complex, "txpath.dat"))
Пример #28
0
    def __init__(self, mod_class, demod_class, rx_callback, options):

        gr.top_block.__init__(self)
        self.node_id = options.nodeid
        self.txpath = transmit_path(mod_class, options)
        self.rxpath = receive_path(demod_class, rx_callback, options)

        self.connect(self.txpath)
        self.connect(self.rxpath)
Пример #29
0
    def __init__(self, callback, options):

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.num_channels = len(options.args.split(','))
        print "System is setup with " + str(
            self.num_channels) + " receive chain(s)"

        # Add all visuals
        visuals.add_visuals(self)

        ##################################################
        # Blocks
        ##################################################

        options.bandwidth = 100000000 / 16

        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.num_channels)

        ##################################################
        # Connections
        ##################################################

        for p in range(self.num_channels):
            # Connect USRP's to receive path
            self.connect((self.source, p), (self.rxpath, p))

            # Add v2s
            object_name_v2s = 'vec2stream_' + str(p)
            setattr(
                self, object_name_v2s,
                blocks.vector_to_stream(gr.sizeof_gr_complex * 1,
                                        options.occupied_tones))

            # Connect receive path to v2s
            self.connect((self.rxpath, p), (getattr(self, object_name_v2s), 0))

            # Connect v2s to Constellation
            self.connect((getattr(self, object_name_v2s), 0),
                         (self.qtgui_const_sink_x_0, p))
Пример #30
0
 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)
Пример #31
0
 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)
Пример #32
0
 def _setup_rx_path(self,options):
     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:
             print "Two Rx antennas"
             self.rxpath = receive_path_12(options)
Пример #33
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)


        self._tx_freq            = options.tx_freq         # tranmitter's center frequency
        self._tx_subdev_spec     = options.tx_subdev_spec  # daughterboard to use
        self._interp             = options.interp          # interpolating rate for the USRP (prelim)
        self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain
        self._rx_subdev_spec     = options.rx_subdev_spec  # daughterboard to use
        self._decim              = options.decim           # Decimating rate for the USRP (prelim)
        self._fusb_block_size    = options.fusb_block_size # usb info for USRP
        self._fusb_nblocks       = options.fusb_nblocks    # usb info for USRP
        
        # linklab
        self.carrier_map         = options.carrier_map     # carrier map
        self.occupied_tones      = options.occupied_tones  # occupied tones
        self.which               = options.which           # usrp in use 
        self.id                  = options.id              # link ID
        self.nosense             = options.nosense         # sensing or not
        self.tx_amplitude        = options.tx_amplitude    # tx amplitude
        self._fft_length         = options.fft_length      # fft length
        self._strategy           = options.strategy         # spectrum access strategy
        
        if self._tx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
            raise SystemExit

        if self._rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP sink and source
        self._setup_usrp_sink()
        ok = self.set_snk_freq(self._tx_freq)
        if not ok:
            print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),)
            raise ValueError

        self._setup_usrp_source()
        ok = self.set_src_freq(self._tx_freq)
        if not ok:
            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(self._tx_freq),)
            raise ValueError

        # copy the final answers back into options for use by modulator
        #options.bitrate = self._bitrate

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

        self.connect(self.txpath, self.u_snk)
        self.connect(self.u_src, self.rxpath)
        
        #if options.sender and not self.nosense:
        self.connect(self.u_src, self.senspath)
Пример #34
0
 def __init__(self, rx_callback, options):
     #gr.top_block.__init__(self)
     grc_wxgui.top_block_gui.__init__(self, title="Receiver")
     
     #Set up reveive path 
     self.rxpath = receive_path.receive_path(self,rx_callback, options)
     
     #the all blocs are connected
     self.connect(self.rxpath)
Пример #35
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()
Пример #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
    def __init__(self, mod_class, demod_class,
                 tx_subdev_spec, rx_subdev_spec,
                 rx_callback,
                 options, kwargs):

        gr.flow_graph.__init__(self)
        self.txpath = transmit_path(self, mod_class, tx_subdev_spec,
                                    options.bitrate, options.interp, options.spb,
                                    options.tx_gain, options, kwargs)
        self.rxpath = receive_path(self, demod_class, rx_subdev_spec,
                                   options.bitrate, options.decim, options.spb,
                                   rx_callback, options, {})
Пример #38
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)
Пример #39
0
    def __init__(self,callback,options):

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000
        self.num_channels = len(options.args.split(','))
        print "System is setup with "+str(self.num_channels)+" receive chain(s)"

        # Add all visuals
        visuals.add_visuals(self)

        ##################################################
        # Blocks
        ##################################################

        options.bandwidth = 100000000/16

        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.num_channels)

        ##################################################
        # Connections
        ##################################################

        for p in range(self.num_channels):
            # Connect USRP's to receive path
            self.connect((self.source,p), (self.rxpath,p))

            # Add v2s
            object_name_v2s = 'vec2stream_'+str(p)
            setattr(self, object_name_v2s, blocks.vector_to_stream(gr.sizeof_gr_complex*1,options.occupied_tones))

            # Connect receive path to v2s
            self.connect((self.rxpath,p), (getattr(self,object_name_v2s), 0))

            # Connect v2s to Constellation
            self.connect( (getattr(self,object_name_v2s), 0), (self.qtgui_const_sink_x_0, p))
Пример #40
0
    def __init__(self, rx_callback, options):
        gr.hier_block2.__init__(self, "usrp_receive_path",
                        gr.io_signature(0, 0, 0),                    # Input signature
                        gr.io_signature(0, 0, 0)) # Output signature
        if options.rx_freq is None:
            sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit
        rx_path = receive_path.receive_path(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))

        self._setup_source(options)
        self.connect(self.u, rx_path)
Пример #41
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        if not options.channel_off:
            SNR = 10.0**(options.snr/10.0)
            power_in_signal = abs(options.tx_amplitude)**2.0
            noise_power_in_channel = power_in_signal/SNR
            noise_voltage = math.sqrt(noise_power_in_channel/2.0)
            print "Noise voltage: ", noise_voltage

            frequency_offset = options.frequency_offset / options.fft_length
            print "Frequency offset: ", frequency_offset

            if options.multipath_on:
                taps = [1.0, .2, 0.0, .1, .08, -.4, .12, -.2, 0, 0, 0, .3]
            else:
                taps = [1.0, 0.0]

        else:
            noise_voltage = 0.0
            frequency_offset = 0.0
            taps = [1.0, 0.0]

        symbols_per_packet = math.ceil(((4+options.size+4) * 8) / options.occupied_tones)
        samples_per_packet = (symbols_per_packet+2) * (options.fft_length+options.cp_length)
        print "Symbols per Packet: ", symbols_per_packet
        print "Samples per Packet: ", samples_per_packet
        if options.discontinuous:
            stream_size = [100000, int(options.discontinuous*samples_per_packet)]
        else:
            stream_size = [0, 100000]

        z = [0,]
        self.zeros = gr.vector_source_c(z, True)
        self.txpath = transmit_path(options)

        #self.mux = gr.stream_mux(gr.sizeof_gr_complex, stream_size)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
        self.channel = gr.channel_model(noise_voltage, frequency_offset,
                                        options.clockrate_ratio, taps)
        self.rxpath = receive_path(callback, options)
                
        #self.connect(self.zeros, (self.mux,0))
        #self.connect(self.txpath, (self.mux,1))
        #self.connect(self.mux, self.throttle, self.channel, self.rxpath)
        #self.connect(self.mux, self.throttle, self.rxpath)
        self.connect(self.txpath, self.throttle, self.channel, self.rxpath)
        
        if options.log:
            self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, "txpath.dat"))
Пример #42
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        #self._tx_freq            = options.tx_freq         # tranmitter's center frequency
        self._tx_gain = options.tx_gain  # transmitter's gain
        self._samp_rate = options.samp_rate  # sample rate for USRP
        #self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain = options.rx_gain  # receiver's gain

        #if self._tx_freq is None:
        #    sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
        #    raise SystemExit

        #if self._rx_freq is None:
        #    sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
        #    raise SystemExit

        # Set up USRP sink and source
        self._setup_usrp_sink()
        self._setup_usrp_source()

        self.txpath = transmit_path(options)
        self.rxpath = receive_path(callback, options)
        self.rx_valve = gr.copy(gr.sizeof_gr_complex)

        self.sense = sense_path(self.set_freq, options)

        # Set center frequency of USRP
        ok = self.set_freq(self.sense.channels[0])  #self._tx_freq)
        if not ok:
            print "Failed to set Tx frequency to %s" % (
                eng_notation.num_to_str(self.sense.channels[0]), )
            raise ValueError

        self.sense_valve = gr.copy(gr.sizeof_gr_complex)

        self.rx_valve.set_enabled(True)
        self.sense_valve.set_enabled(False)

        self.connect(self.txpath, self.u_snk)
        self.connect(self.u_src, self.rx_valve, self.rxpath)
        self.connect(self.u_src, self.sense_valve, self.sense)

        if options.verbose:
            self._print_verbage()
        if options.show_rx_gain_range:
            print "RX gain range: ", self.u_src.get_gain_range()
        if options.show_tx_gain_range:
            print "TX gain range: ", self.u_snk.get_gain_range()
Пример #43
0
 def _setup_rx_path(self, options):
     if options.tx_ant == 1:
         if options.rx_ant == 1:
             if options.fbmc:
                 print "fbmc_transmit_path"
                 options.est_preamble = 0
                 self.rxpath = fbmc_receive_path(options)
             else:
                 self.rxpath = receive_path(options)
             #self._setup_rpc_manager()
             #self.connect(self.source, self.rxpath)
         else:
             print "1X21X21X21X2"
             #self.rxpath = receive_path(options)
             self.rxpath = receive_path_12(options)
Пример #44
0
 def _setup_rx_path(self,options):
     if options.tx_ant == 1:
         if options.rx_ant == 1:
             if options.fbmc:
                 print "fbmc_transmit_path"
                 options.est_preamble = 0
                 self.rxpath = fbmc_receive_path(options)
             else:
                 self.rxpath = receive_path(options)
             #self._setup_rpc_manager()
             #self.connect(self.source, self.rxpath)
         else:
             print "1X21X21X21X2"
             #self.rxpath = receive_path(options)
             self.rxpath = receive_path_12(options)
Пример #45
0
    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)
Пример #46
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        #self._tx_freq            = options.tx_freq         # tranmitter's center frequency
        self._tx_gain            = options.tx_gain         # transmitter's gain
        self._samp_rate          = options.samp_rate       # sample rate for USRP
        #self._rx_freq            = options.rx_freq         # receiver's center frequency
        self._rx_gain            = options.rx_gain         # receiver's gain

        #if self._tx_freq is None:
        #    sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
        #    raise SystemExit

        #if self._rx_freq is None:
        #    sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
        #    raise SystemExit

        # Set up USRP sink and source
        self._setup_usrp_sink()
        self._setup_usrp_source()

        self.txpath = transmit_path(options)
        self.rxpath = receive_path(callback, options)
        self.rx_valve = gr.copy(gr.sizeof_gr_complex)
                
        self.sense = sense_path(self.set_freq, options)
        
        # Set center frequency of USRP
        ok = self.set_freq(self.sense.channels[0]) #self._tx_freq)
        if not ok:
            print "Failed to set Tx frequency to %s" % (eng_notation.num_to_str(self.sense.channels[0]),)
            raise ValueError
        
        self.sense_valve = gr.copy(gr.sizeof_gr_complex)
        
        self.rx_valve.set_enabled(True)
        self.sense_valve.set_enabled(False)

        self.connect(self.txpath, self.u_snk)
        self.connect(self.u_src, self.rx_valve, self.rxpath)
        self.connect(self.u_src, self.sense_valve, self.sense)
        
        if options.verbose:
            self._print_verbage()
        if options.show_rx_gain_range:
            print "RX gain range: ", self.u_src.get_gain_range()
        if options.show_tx_gain_range:
            print "TX gain range: ", self.u_snk.get_gain_range()
Пример #47
0
    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)
Пример #48
0
    def setup_receiver_usrp0(self):
        self.tb = gr.top_block()
        

        
        
        
        
        self.rxpath = receive_path(self)
        
        self.rpc_mgr_rx = zeromq.rpc_manager()
        self.rpc_mgr_rx.set_reply_socket("tcp://*:5550")
        self.rpc_mgr_rx.start_watcher()

       ## Adding interfaces
        self.rpc_mgr_rx.add_interface("set_scatter_subcarrier",self.rxpath.set_scatterplot_subc)
Пример #49
0
    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)
Пример #50
0
    def __init__(self, mod_class, demod_class, rx_callback, options):
        gr.top_block.__init__(self)

        channelon = True

        SNR = 10.0**(options.snr / 10.0)
        frequency_offset = options.frequency_offset

        power_in_signal = abs(options.tx_amplitude)**2
        noise_power = power_in_signal / SNR
        noise_voltage = math.sqrt(noise_power)

        # With new interface, sps does not get set by default, but
        # in the loopback, we don't recalculate it; so just force it here
        if (options.samples_per_symbol == None):
            options.samples_per_symbol = 2

        self.txpath = transmit_path(mod_class, options)
        self.throttle = gr.throttle(gr.sizeof_gr_complex, options.sample_rate)
        self.rxpath = receive_path(demod_class, rx_callback, options)

        if channelon:
            self.channel = gr.channel_model(noise_voltage, frequency_offset,
                                            1.01)

            if options.discontinuous:
                z = 20000 * [
                    0,
                ]
                self.zeros = gr.vector_source_c(z, True)
                packet_size = 5 * ((4 + 8 + 4 + 1500 + 4) * 8)
                self.mux = gr.stream_mux(
                    gr.sizeof_gr_complex,
                    [packet_size - 0, int(9e5)])

                # Connect components
                self.connect(self.txpath, (self.mux, 0))
                self.connect(self.zeros, (self.mux, 1))
                self.connect(self.mux, self.channel, self.rxpath)

            else:
                self.connect(self.txpath, self.channel, self.rxpath)

        else:
            # Connect components
            self.connect(self.txpath, self.throttle, self.rxpath)
Пример #51
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)
Пример #52
0
    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)
Пример #53
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)
Пример #54
0
    def __init__(self, rx_callback, options):
        gr.hier_block2.__init__(
            self,
            "usrp_receive_path",
            gr.io_signature(0, 0, 0),  # Input signature
            gr.io_signature(0, 0, 0))  # Output signature
        #if options.rx_freq is None:
        #sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
        #raise SystemExit
        rx_path = receive_path.receive_path(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))

        self._setup_source(options)
        self.connect(self.u, rx_path)

        if options.verbose:
            print 'USRP Source:', self.u
Пример #55
0
    def __init__(self, callback, options):
        gr.top_block.__init__(self)

        self._tx_freq = options.tx_freq  # tranmitter's center frequency
        self._tx_subdev_spec = options.tx_subdev_spec  # daughterboard to use
        self._interp = options.interp  # interpolating rate for the USRP (prelim)
        self._rx_freq = options.rx_freq  # receiver's center frequency
        self._rx_gain = options.rx_gain  # receiver's gain
        self._rx_subdev_spec = options.rx_subdev_spec  # daughterboard to use
        self._decim = options.decim  # Decimating rate for the USRP (prelim)
        self._fusb_block_size = options.fusb_block_size  # usb info for USRP
        self._fusb_nblocks = options.fusb_nblocks  # usb info for USRP

        if self._tx_freq is None:
            sys.stderr.write(
                "-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n")
            raise SystemExit

        if self._rx_freq is None:
            sys.stderr.write(
                "-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n")
            raise SystemExit

        # Set up USRP sink and source
        self._setup_usrp_sink()
        self._setup_usrp_source()

        # Set center frequency of USRP
        ok = self.set_freq(self._tx_freq)
        if not ok:
            print "Failed to set Tx frequency to %s" % (
                eng_notation.num_to_str(self._tx_freq), )
            raise ValueError

        # copy the final answers back into options for use by modulator
        #options.bitrate = self._bitrate

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

        self.connect(self.txpath, self.u_snk)
        self.connect(self.u_src, self.rxpath)
Пример #56
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)
Пример #57
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)