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)
def __init__(self, modulator, options): gr.top_block.__init__(self) 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) # 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.sink)
def __init__(self, options): gr.top_block.__init__(self) self._tx_freq = options.tx_freq # tranmitter's center frequency self._rate = options.rate #*options.num_channels # USRP sample rate self.gain = options.gain # USRP 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 # Set up USRP sink; also adjusts interp, and bitrate self._setup_usrp_sink() # copy the final answers back into options for use by modulator #options.bitrate = self._bitrate self.txpath = transmit_path(options) self.connect(self.txpath, self.u) #self.connect(self.txpath, gr.file_sink(gr.sizeof_gr_complex, "txpath.dat")) if options.verbose: self._print_verbage()
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
def __init__(self, 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._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._tx_freq is None: sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") raise SystemExit # Set up USRP sink; also adjusts interp, and bitrate self.u_sink = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args(cpu_format="fc32", channels=range(1),)) print "Setting Tx Params. Fs=%e, Fc=%e, G=%f"%(self._bandwidth, self._tx_freq, self._tx_gain) self.u_sink.set_samp_rate(self._bandwidth) self.u_sink.set_center_freq(self._tx_freq) self.u_sink.set_gain(self._tx_gain) # copy the final answers back into options for use by modulator #options.bitrate = self._bitrate self.txpath = transmit_path(options) self.connect(self.txpath, self.u_sink)
def __init__(self, modulator_class, options): gr.top_block.__init__(self) self.txpath = transmit_path(modulator_class, options) self.audio_rx = audio_rx(options.audio_input) if(options.tx_freq is not None): self.sink = uhd_transmitter(options.address, options.bitrate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.verbose) options.samples_per_symbol = self.sink._sps audio_rate = self.audio_rx.sample_rate usrp_rate = self.sink.get_sample_rate() rrate = usrp_rate / audio_rate elif(options.to_file is not None): self.sink = blocks.file_sink(gr.sizeof_gr_complex, options.to_file) rrate = 1 else: self.sink = blocks.null_sink(gr.sizeof_gr_complex) rrate = 1 self.resampler = filter.pfb.arb_resampler_ccf(rrate) self.connect(self.audio_rx) self.connect(self.txpath, self.resampler, self.sink)
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)
def __init__(self, modulator_class, options): ''' See below for what options should hold ''' gr.hier_block2.__init__( self, "usrp_transmit_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature if options.tx_freq is None: sys.stderr.write( "-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") raise SystemExit #setup usrp self._modulator_class = modulator_class self._setup_usrp_sink(options) tx_path = transmit_path.transmit_path(modulator_class, options) for attr in dir(tx_path): #forward the methods if not attr.startswith('_') and not hasattr(self, attr): setattr(self, attr, getattr(tx_path, attr)) #connect self.connect(tx_path, self.u)
def _setup_tx_path(self,options): print "OPTIONS", options if options.fbmc: print "fbmc_transmit_path" self.txpath = fbmc_transmit_path(options) else: self.txpath = transmit_path(options)
def __init__(self, options): gr.top_block.__init__(self) self.samp_rate = samp_rate = 1000000 self.band_width = band_width = 20000000 if (options.tx_freq is not None): self.sink = iio.pluto_sink('193.168.2.1', options.tx_freq, samp_rate, long(options.bandwidth), 0x8000, 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) 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) # 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)
def __init__(self, modulator, options): gr.top_block.__init__(self) options.constellation_points = 4 #options.tx_freq += 0.75e6 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.lo_offset, options.tx_gain, options.spec, options.antenna, options.clock_source, 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 = blocks.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 = blocks.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(modulator, options) self.connect(self.txpath, self.sink) print >> sys.stderr, options
def _setup_tx_path(self, options): print "OPTIONS", options if options.fbmc: print "fbmc_transmit_path" self.txpath = fbmc_transmit_path(options) else: self.txpath = transmit_path(options)
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)
def __init__(self, modulator, options): gr.top_block.__init__(self) if (options.tx_freq is not None): # Work-around to get the modulation's bits_per_symbol kwargs = modulator.extract_kwargs_from_options(options) symbol_rate = options.bitrate / modulator( **kwargs).bits_per_symbol() self.sink = osmo_transmitter(options.args, symbol_rate, options.samples_per_symbol, options.tx_freq, options.tx_gain, options.antenna, options.bandwidth) 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 = blocks.null_sink(gr.sizeof_gr_complex) # do this after for any adjustments to the options that may # occur in the sinks (specifically the Osmosdr sink) self.txpath = transmit_path(modulator, options) self.connect(self.txpath, self.sink)
def __init__(self, modulator, options): # Get options from call, modulator and options gr.top_block.__init__(self) 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) # do this after for any adjustments to the options that may # occur in the sinks (specifically the UHD sink) # Pass options to transmitter, setup transmitter, pass to pointer self.txpath self.txpath = transmit_path(modulator, options) # Connect and construct flowgraph self.connect( self.txpath, self.sink) #--> back to main, to enable realtime scheduling
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)
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)
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, options): grc_wxgui.top_block_gui.__init__(self, title="Top Block") #gr.top_block.__init__(self) #construction of the transmit path of the USRP self.txpath = transmit_path.transmit_path(self, options) self.connect(self.txpath)
def __init__(self, modulator, options): gr.top_block.__init__(self) print "Saving samples to '%s'.\n" % (options.samples_file) self.sink = gr.file_sink(gr.sizeof_gr_complex, options.samples_file) self.txpath = transmit_path(modulator, options) self.connect(self.txpath, self.sink)
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);
def __init__(self, options): gr.top_block.__init__(self) self.sink = self._setup_osmosdr(options) self.txpath = transmit_path(options) self.connect(self.txpath, self.sink)
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"))
def __init__(self, options): gr.top_block.__init__(self) 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.connect(self.txpath, self.sink)
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)
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)
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, 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)
def setup_transmitter_usrp0(self): self.tb = gr.top_block() self.txpath = transmit_path(self) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_reply_socket("tcp://*:6660") self.rpc_mgr_tx.start_watcher() ## Adding interfaces self.rpc_mgr_tx.add_interface("set_amplitude",self.txpath.set_rms_amplitude) self.rpc_mgr_tx.add_interface("get_tx_parameters",self.txpath.get_tx_parameters) self.rpc_mgr_tx.add_interface("set_modulation",self.txpath.allocation_src.set_allocation)
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, {})
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)
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"))
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()
def setup_transmitter_usrp0(self): self.tb = gr.top_block() self.txpath = transmit_path(self) self.rpc_mgr_tx = zeromq.rpc_manager() self.rpc_mgr_tx.set_reply_socket("tcp://*:6660") self.rpc_mgr_tx.start_watcher() ## Adding interfaces self.rpc_mgr_tx.add_interface("set_amplitude", self.txpath.set_rms_amplitude) self.rpc_mgr_tx.add_interface("get_tx_parameters", self.txpath.get_tx_parameters) self.rpc_mgr_tx.add_interface( "set_modulation", self.txpath.allocation_src.set_allocation)
def __init__(self, options): gr.hier_block2.__init__(self, "usrp_transmit_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature if options.tx_freq is None: sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") raise SystemExit tx_path = transmit_path.transmit_path(options) for attr in dir(tx_path): #forward the methods if not attr.startswith('_') and not hasattr(self, attr): setattr(self, attr, getattr(tx_path, attr)) self._setup_sink(options) self.connect(tx_path, self.sink)
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()
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)
def __init__(self, options): gr.top_block.__init__(self) self.sink = uhd_transmitter(options.args, options.bandwidth, options.tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) # 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)
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)
def clickStart (self, event): #self.condition.acquire() self.button_commencer.Disable() self.button_arreter.Enable() self.setOptionsGui() #initialiser les options de transmission par ceux de l'interface graphique self.setOptionsReal() #self.tb.changeOptionsTransmitter(self.options) self.tb = transmit_path(self.options, self.state_mod) print "amplitude initial ", self.options.amplitude #self.th_premiers_op = Thread_Premiers_Options(self.options) self.th_cliq_commencer = Thread_click_start(self, self.tb)
def _setup_usrp_source2(self, options): """ Creates a USRP sink, determines the settings for best bitrate, and attaches to the transmitter's subdevice. """ print "setup_usrp_source2", self._tx_freq if (self._tx_freq is not None): self.u_sink = uhd_transmitter(options.args, options.bandwidth, self._tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) print "setup usrp sink ", self.u_sink # 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.u_sink)
def __init__(self, modulator, options): gr.top_block.__init__(self) 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.lo_offset, options.tx_gain, options.spec, options.antenna, options.clock_source, 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 = blocks.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 = blocks.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(modulator, options) alpha = 0.001 thresh = 20 self.probe = analog.probe_avg_mag_sqrd_c(thresh,alpha) self.source = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.source.set_samp_rate(self.sink._rate) self.source.set_center_freq(uhd.tune_request(options.tx_freq,0)) self.source.set_gain(options.tx_gain) self.connect(self.source, self.probe) self.connect(self.txpath, self.sink) print >> sys.stderr, options
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)
def _setup_usrp_source2(self,options): """ Creates a USRP sink, determines the settings for best bitrate, and attaches to the transmitter's subdevice. """ print "setup_usrp_source2",self._tx_freq if(self._tx_freq is not None): self.u_sink = uhd_transmitter(options.args, options.bandwidth, self._tx_freq, options.tx_gain, options.spec, options.antenna, options.verbose) print "setup usrp sink " , self.u_sink # 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.u_sink)
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) 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)
def __init__(self): gr.top_block.__init__(self) self.uhd_sink = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_sink.set_samp_rate(samp_rate) self.uhd_sink.set_center_freq(f_center, 0) self.uhd_sink.set_gain(gain, 0) self.uhd_sink.set_bandwidth(bandwidth, 0) self.txpath = transmit_path() #self.rxpath = receive_path(callback, options) self.connect(self.txpath, self.uhd_sink)
def __init__(self, modulator_class, options): ''' See below for what options should hold ''' gr.hier_block2.__init__(self, "usrp_transmit_path", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(0, 0, 0)) # Output signature if options.tx_freq is None: sys.stderr.write("-f FREQ or --freq FREQ or --tx-freq FREQ must be specified\n") raise SystemExit tx_path = transmit_path.transmit_path(modulator_class, options) for attr in dir(tx_path): #forward the methods if not attr.startswith('_') and not hasattr(self, attr): setattr(self, attr, getattr(tx_path, attr)) #setup usrp self._modulator_class = modulator_class self._setup_usrp_sink(options) #connect self.connect(tx_path, self.u)
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.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) # 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)
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)
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)
def __init__(self, options): gr.top_block.__init__(self, "tx_mpsk") self._transmitter = transmit_path(options.sps, options.excess_bw, options.amplitude) if_rate = options.rate*options.sps interp = int(_dac_rate/if_rate) print "Modulation:", n2s(options.rate), "bits/sec" print "TX IF rate:", n2s(if_rate), "samples/sec" print "USRP interpolation:", interp print "DAC amplitude:", options.amplitude self._setup_usrp(options.which, interp, options.tx_subdev_spec, options.freq) self.connect(self._transmitter, self._usrp)
def __init__(self, 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._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 # Set up USRP sink; also adjusts interp, and bitrate self._setup_usrp_sink() # copy the final answers back into options for use by modulator #options.bitrate = self._bitrate self.txpath = transmit_path(options) self.connect(self.txpath, self.u)
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)