def __init__(self, istx, ismimo, args, bandwidth, freq=None, lo_offset=None, gain=None, spec=None, antenna=None, clock_source=None, time_source=None): # check the USRP model name print "Assuming only one type of USRP. Checking USRP model..." usrp = uhd.usrp_source(device_addr=uhd.device_addr_t(''), stream_args=uhd.stream_args('fc32')) self._usrp_model = usrp.get_usrp_info().get("mboard_id") print "Using USRP model:", self._usrp_model del(usrp) if(istx): if self._usrp_model == 'USRP1': # load special FPGA bitstream to get a flat frequency response print "Loading special FPGA bitstream for USRP1 Tx to obtain flat frequency response" UHD_DIR = os.environ.get("UHD_DIR") if UHD_DIR != None and UHD_DIR != "": args = uhd.device_addr_t('fpga=' + UHD_DIR + 'share/uhd/images/std_1rxhb_1txhb.rbf') else: args = uhd.device_addr_t('fpga=/usr/share/uhd/images/std_1rxhb_1txhb.rbf') self.u = uhd.usrp_sink(device_addr=args, stream_args=uhd.stream_args('fc32')) else: if(ismimo): self.u = uhd.usrp_source(device_addr=" addr0=192.168.10.2, addr1=192.168.10.3", stream_args=uhd.stream_args('fc32',channels=range(2))) else: self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32')) #Make adjustments for USRP1 halfband filters if istx and self._usrp_model == 'USRP1': bandwidth=(bandwidth/2.0) # write the other parameters to member variables self._istx=istx self._args = args self._ant = antenna self._ismimo = ismimo self._spec = spec self._gain = self.set_gain(gain) self._lo_offset = lo_offset self._rate = self.set_sample_rate(bandwidth) self._freq = self.set_freq(freq, lo_offset) self._clock_source = clock_source self._time_source = time_source # Set clock source to external. if(clock_source): print "clock_source: ", clock_source self.u.set_clock_source(clock_source, 0) if(time_source): print "time_source: ", time_source self.u.set_time_source(time_source, 0) # Set the subdevice spec if(spec): self.u.set_subdev_spec(spec, 0) # Set the antenna if(antenna): self.u.set_antenna(antenna, 0)
def __init__(self): search_criteria = uhd.device_addr_t() search_criteria['type'] = 'b200' # ensure we don't find networked usrp available_devices = list(uhd.find_devices(search_criteria)) ndevices_found = len(available_devices) if ndevices_found != 1: err = "Found {} devices that matches USRP identification\n" err += "information in sysinfo:\n" err += search_criteria.to_pp_string() err += "\nPlease add/correct identifying information." err = err.format(ndevices_found) for device in available_devices: err += " {}\n".format(device.to_pp_string()) raise RuntimeError(err) device = available_devices[0] logger.debug("Using the following USRP:") logger.debug(device.to_pp_string()) stream_args = uhd.stream_args('fc32') self.usrp = uhd.usrp_source(device_addr=device, stream_args=stream_args) self.usrp.set_auto_dc_offset(True)
def __init__(self, cfg): self.logger = logging.getLogger('gr-analyzer.usrp') self.stream_args = uhd.stream_args(cpu_format=cfg.cpu_format, otw_format=cfg.wire_format, args=cfg.stream_args) found_devices = uhd.find_devices(uhd.device_addr_t(cfg.device_addr)) len_found_devices = len(found_devices) if len_found_devices is 1: self.device_addr = found_devices[0] self.logger.debug("Found device {!s}".format(self.device_addr)) else: if len_found_devices > 1: err = "\n\nFound more than 1 USRP:\n\n" err += str(found_devices) err += "\n\n" err += "Use --device-addr to select desired device.\n" err += " example: --device-addr='serial=*****,addr=192.168.*.*'" err += "\n\n" else: err = "No devices found." raise RuntimeError(err) self.uhd = uhd.usrp_source(device_addr=self.device_addr, stream_args=self.stream_args) self.clock_rate = int(self.uhd.get_clock_rate()) self.sample_rate = int(self.uhd.get_samp_rate()) self.apply_cfg(cfg)
def constructor_interceptor(*args, **kwargs): args = list(args) kwargs = dict(kwargs) if len(args) > 0: args[0] = uhd.device_addr_t(args[0]) if kwargs.has_key('uhd_args'): kwargs['uhd_args'] = device_addr(kwargs['uhd_args']) # Don't pass kwargs, it confuses swig, instead map into args list. for key in ('uhd_args', 'poll_interval'): if kwargs.has_key(key): args.append(kwargs[key]) return old_constructor(*args)
def __init__(self, profile): self.profile = profile search_criteria = uhd.device_addr_t() if profile.usrp_device_name is not None: search_criteria['name'] = profile.usrp_device_name if profile.usrp_device_type is not None: search_criteria['type'] = profile.usrp_device_type if profile.usrp_serial is not None: search_criteria['serial'] = profile.usrp_serial if profile.usrp_ip_address is not None: search_criteria['addr'] = profile.usrp_ip_address found_devices = uhd.find_devices(search_criteria) if len(found_devices) != 1: err = "Found {} devices that matches USRP identification\n" err += "information in the test profile:\n" err += search_criteria.to_pp_string() err += "Please add/correct identifying information.\n" print(err, file=sys.stderr) for device in found_devices: print() print(device.to_pp_string()) print() raise RuntimeError() else: device = found_devices[0] print("Found the following USRP matching test profile criteria:\n") print(device.to_pp_string()) stream_args = uhd.stream_args(profile.usrp_stream_args) self.usrp = uhd.usrp_source(device_addr=device, stream_args=stream_args) self.usrp.set_auto_dc_offset(True) self.usrp.set_clock_rate(profile.usrp_clock_rate) self.usrp.set_samp_rate(profile.usrp_sample_rate) self.sample_rate = self.usrp.get_samp_rate() print("USRP actual sample rate: {} MS/s".format(self.sample_rate / 1e6)) for gain_type, value in profile.usrp_gain.items(): self.usrp.set_gain(value, gain_type) print("USRP gain: {} dB".format(self.usrp.get_gain())) if hasattr(profile, 'usrp_center_freq'): self.set_frequency(profile.usrp_center_freq)
def increment_channel(self): for ii in range(len(self.u_rxs)): self.center_freqs[ii] = self.center_freqs[ii] + STEP_FREQ if self.center_freqs[ii] > END_FREQ: self.center_freqs[ii] = START_FREQ self.tr = uhd.tune_request(self.center_freqs[ii]) self.tr.args = uhd.device_addr_t("mode_n=integer") self.u_txs[ii].set_center_freq(self.tr) progress_frac = (self.center_freqs[ii] - START_FREQ) / (END_FREQ - START_FREQ) tx_gain = (1 - progress_frac ) * START_TX_GAIN + progress_frac * END_TX_GAIN self.u_txs[ii].set_gain( tx_gain ) #TX (and RX) gain is inconsistent across freuqency, so we compensate... self.u_rxs[ii - self.trxoff].set_center_freq(self.tr)
def increment_channel(self): self.center_freq = self.center_freq + STEP_FREQ if self.center_freq > END_FREQ: self.center_freq = START_FREQ print "Setting frequency to %f" % (self.center_freq) self.tr = uhd.tune_request(self.center_freq) self.tr.args = uhd.device_addr_t("mode_n=integer") self.u_tx.set_center_freq(self.tr) progress_frac = (self.center_freq - START_FREQ) / (END_FREQ - START_FREQ) tx_gain = (1 - progress_frac) * START_TX_GAIN + progress_frac * END_TX_GAIN print("setting tx gain to {}...".format(tx_gain)) self.u_tx.set_gain( tx_gain ) #TX (and RX) gain is inconsistent across freuqency, so we compensate... for u_rx in self.u_rxs: u_rx.set_center_freq(self.tr)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.device3 = variable_uhd_device3_0 = ettus.device3( uhd.device_addr_t(",".join(("type=x300", "addr=192.168.10.2")))) self.samp_rate = samp_rate = 20e6 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.uhd_rfnoc_streamer_schmidlcox_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", channels=(0, ), args="", ), uhd.stream_args( # RX Stream Args cpu_format="fc32", otw_format="sc16", channels=(0, ), args="", ), "SchmidlCox", -1, -1, ) self.uhd_rfnoc_streamer_schmidlcox_0.set_register(0x10, 64) # Frame length self.uhd_rfnoc_streamer_schmidlcox_0.set_register(0x11, 16) # CP length self.uhd_rfnoc_streamer_schmidlcox_0.set_register( 0x12, 22) # samples to wait after trigger self.uhd_rfnoc_streamer_schmidlcox_0.set_register( 0x13, 2) # max number of frames to process self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="spp=64,magnitude_out=0", ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "FFT", -1, -1, ) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/julian/git/ofdm-sync/octave-sym/test-float.bin", True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, "/home/julian/Desktop/output.bin", False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink2_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.uhd_rfnoc_streamer_schmidlcox_0, 0)) self.connect((self.uhd_rfnoc_streamer_fft_0, 0), (self.blocks_vector_to_stream_0, 0)) self.device3.connect( self.uhd_rfnoc_streamer_schmidlcox_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0)
def __init__(self): gr.top_block.__init__(self, "Msod Sslsensor X310 Rfnoc") Qt.QWidget.__init__(self) self.setWindowTitle("Msod Sslsensor X310 Rfnoc") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "MSOD_SSLSensor_X310_RFNoC") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.fft_size = fft_size = 256 self.num_ch = num_ch = 50 self.hz_per_bin = hz_per_bin = samp_rate / fft_size self.bandwidth = bandwidth = 9e6 self.meas_interval = meas_interval = 1e-3 self.channel_bw = channel_bw = hz_per_bin * round( bandwidth / num_ch / hz_per_bin) self.device3 = variable_uhd_device3_0 = ettus.device3( uhd.device_addr_t(",".join(("type=x300", "addr=usrp0")))) self.rx_gain = rx_gain = 0 self.meas_period = meas_period = max( 1, int(round(meas_interval * samp_rate / fft_size))) self.impedance = impedance = 50.0 self.dest_host = dest_host = "129.6.142.138" self.center_freq = center_freq = 724e6 self.ActualBW = ActualBW = channel_bw * num_ch ################################################## # Blocks ################################################## self._samp_rate_options = ( 10e6, 25e6, 12.5e6, 3.84e6, 5e5, ) self._samp_rate_labels = ( "10e6", "25e6", "12.5e6", "3.84e6", "5e5", ) self._samp_rate_group_box = Qt.QGroupBox("samp_rate") self._samp_rate_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._samp_rate_button_group = variable_chooser_button_group() self._samp_rate_group_box.setLayout(self._samp_rate_box) for i, label in enumerate(self._samp_rate_labels): radio_button = Qt.QRadioButton(label) self._samp_rate_box.addWidget(radio_button) self._samp_rate_button_group.addButton(radio_button, i) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_button_group.buttonClicked[int].connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_group_box) self._rx_gain_range = Range(0, 31.5, 0.5, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._num_ch_options = ( 56, 50, 25, 15, 8, ) self._num_ch_labels = ( "56", "50", "25", "15", "8", ) self._num_ch_group_box = Qt.QGroupBox("num_ch") self._num_ch_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._num_ch_button_group = variable_chooser_button_group() self._num_ch_group_box.setLayout(self._num_ch_box) for i, label in enumerate(self._num_ch_labels): radio_button = Qt.QRadioButton(label) self._num_ch_box.addWidget(radio_button) self._num_ch_button_group.addButton(radio_button, i) self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod( self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i))) self._num_ch_callback(self.num_ch) self._num_ch_button_group.buttonClicked[int].connect( lambda i: self.set_num_ch(self._num_ch_options[i])) self.top_layout.addWidget(self._num_ch_group_box) self._fft_size_options = ( 2048, 1024, 512, 256, 128, ) self._fft_size_labels = ( "2048", "1024", "512", "256", "128", ) self._fft_size_tool_bar = Qt.QToolBar(self) self._fft_size_tool_bar.addWidget(Qt.QLabel("fft_size" + ": ")) self._fft_size_combo_box = Qt.QComboBox() self._fft_size_tool_bar.addWidget(self._fft_size_combo_box) for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label) self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod( self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i))) self._fft_size_callback(self.fft_size) self._fft_size_combo_box.currentIndexChanged.connect( lambda i: self.set_fft_size(self._fft_size_options[i])) self.top_layout.addWidget(self._fft_size_tool_bar) self._center_freq_options = ( 709.01e6, 782e6, 724e6, ) self._center_freq_labels = ( "AT&T", "Verizon", "ChannelEmulator", ) self._center_freq_tool_bar = Qt.QToolBar(self) self._center_freq_tool_bar.addWidget(Qt.QLabel("center_freq" + ": ")) self._center_freq_combo_box = Qt.QComboBox() self._center_freq_tool_bar.addWidget(self._center_freq_combo_box) for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_layout.addWidget(self._center_freq_tool_bar) self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625), ), uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625), ), "VectorIIR", -1, -1, ) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", 0.984375) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta", 0.015625) self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args="spp=256", ), 0, -1) self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq) self.uhd_rfnoc_streamer_radio_0.set_rx_rate(samp_rate) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain) self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("TX/RX") self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True) self.uhd_rfnoc_streamer_logpwr_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format( num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format( num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)), ), "LogPwr", -1, -1, ) self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format( fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format( fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)), ), "FIFO", -1, -1, ) self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="spp={},magnitude_out={}".format(256, "COMPLEX"), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "FFT", -1, -1, ) self.uhd_rfnoc_streamer_bin_aggr_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args=""), uhd.stream_args( cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "BinAggr", -1, -1, ) self.msod_sensor_jsonfile_sink_0 = msod_sensor.jsonfile_sink( num_ch, "/home/nae/capture/capture_X310/03_25_2016-002.dat", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.loc", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.sys", "X310", "NaN", center_freq, ActualBW, meas_interval, 0, samp_rate, False) self._dest_host_options = ( "pwct1.ctl.nist.gov", "129.6.230.12", "129.6.142.181", "129.6.142.138", ) self._dest_host_labels = ( "pwct1", "Naceur Laptop", "pwct5Desktop", "Pwct5", ) self._dest_host_tool_bar = Qt.QToolBar(self) self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host + ": ")) self._dest_host_combo_box = Qt.QComboBox() self._dest_host_tool_bar.addWidget(self._dest_host_combo_box) for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label) self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod( self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i))) self._dest_host_callback(self.dest_host) self._dest_host_combo_box.currentIndexChanged.connect( lambda i: self.set_dest_host(self._dest_host_options[i])) self.top_layout.addWidget(self._dest_host_tool_bar) self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(num_ch) self._bandwidth_options = ( 10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, ) self._bandwidth_labels = ( "10.08e6", "9e6", "4.5e6", "2.7e6", "1.08e6", ) self._bandwidth_tool_bar = Qt.QToolBar(self) self._bandwidth_tool_bar.addWidget(Qt.QLabel("bandwidth" + ": ")) self._bandwidth_combo_box = Qt.QComboBox() self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box) for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label) self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i))) self._bandwidth_callback(self.bandwidth) self._bandwidth_combo_box.currentIndexChanged.connect( lambda i: self.set_bandwidth(self._bandwidth_options[i])) self.top_layout.addWidget(self._bandwidth_tool_bar) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.msod_sensor_jsonfile_sink_0, 0)) self.connect((self.uhd_rfnoc_streamer_logpwr_0, 0), (self.blocks_complex_to_mag_0, 0)) self.device3.connect(self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0, self.uhd_rfnoc_streamer_logpwr_0.get_block_id(), 0) self.device3.connect( self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0, self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0) self.device3.connect( self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0, self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0)
def __init__(self): gr.top_block.__init__(self, "Msod Sslsensor N210") Qt.QWidget.__init__(self) self.setWindowTitle("Msod Sslsensor N210") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "MSOD_SSLSensor_N210") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 12.5e6 self.fft_size = fft_size = 625 self.num_ch = num_ch = 56 self.mywindow = mywindow = window.blackmanharris(fft_size) self.hz_per_bin = hz_per_bin = samp_rate / fft_size self.bandwidth = bandwidth = 10.08e6 self.window_power = window_power = sum(map(lambda x: x * x, mywindow)) self.meas_interval = meas_interval = 1e-3 self.impedance = impedance = 50.0 self.channel_bw = channel_bw = hz_per_bin * round( bandwidth / num_ch / hz_per_bin) self.device3 = variable_uhd_device3_0 = ettus.device3( uhd.device_addr_t(",".join(('type=x300, addr=usrp02', "")))) self.rx_gain = rx_gain = 0 self.meas_period = meas_period = max( 1, int(round(meas_interval * samp_rate / fft_size))) self.dest_host = dest_host = "129.6.142.103" self.center_freq = center_freq = 724e6 self.Vsq2W_dB = Vsq2W_dB = -10.0 * math.log10( fft_size * int(window_power) * impedance) self.ActualBW = ActualBW = channel_bw * num_ch ################################################## # Blocks ################################################## self._samp_rate_options = ( 12.5e6, 15.36e6, 7.68e6, 3.84e6, 1.92e6, ) self._samp_rate_labels = ( '12.5e6', '15.36e6', '7.68e6', '3.84e6', '1.92e6', ) self._samp_rate_group_box = Qt.QGroupBox('samp_rate') self._samp_rate_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._samp_rate_button_group = variable_chooser_button_group() self._samp_rate_group_box.setLayout(self._samp_rate_box) for i, label in enumerate(self._samp_rate_labels): radio_button = Qt.QRadioButton(label) self._samp_rate_box.addWidget(radio_button) self._samp_rate_button_group.addButton(radio_button, i) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_button_group.buttonClicked[int].connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_group_box) self._rx_gain_range = Range(0, 31.5, 0.5, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'rx_gain', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._num_ch_options = ( 56, 50, 25, 15, 8, ) self._num_ch_labels = ( '56', '50', '25', '15', '8', ) self._num_ch_group_box = Qt.QGroupBox('num_ch') self._num_ch_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._num_ch_button_group = variable_chooser_button_group() self._num_ch_group_box.setLayout(self._num_ch_box) for i, label in enumerate(self._num_ch_labels): radio_button = Qt.QRadioButton(label) self._num_ch_box.addWidget(radio_button) self._num_ch_button_group.addButton(radio_button, i) self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod( self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i))) self._num_ch_callback(self.num_ch) self._num_ch_button_group.buttonClicked[int].connect( lambda i: self.set_num_ch(self._num_ch_options[i])) self.top_layout.addWidget(self._num_ch_group_box) self._fft_size_options = ( 625, 1024, 512, 256, 128, ) self._fft_size_labels = ( '625', '1024', '512', '256', '128', ) self._fft_size_tool_bar = Qt.QToolBar(self) self._fft_size_tool_bar.addWidget(Qt.QLabel('fft_size' + ": ")) self._fft_size_combo_box = Qt.QComboBox() self._fft_size_tool_bar.addWidget(self._fft_size_combo_box) for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label) self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod( self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i))) self._fft_size_callback(self.fft_size) self._fft_size_combo_box.currentIndexChanged.connect( lambda i: self.set_fft_size(self._fft_size_options[i])) self.top_layout.addWidget(self._fft_size_tool_bar) self._center_freq_options = ( 709.01e6, 782e6, 724e6, ) self._center_freq_labels = ( 'AT&T', 'Verizon', 'ChannelEmulator', ) self._center_freq_tool_bar = Qt.QToolBar(self) self._center_freq_tool_bar.addWidget(Qt.QLabel('center_freq' + ": ")) self._center_freq_combo_box = Qt.QComboBox() self._center_freq_tool_bar.addWidget(self._center_freq_combo_box) for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_layout.addWidget(self._center_freq_tool_bar) self._bandwidth_options = ( 10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, ) self._bandwidth_labels = ( '10.08e6', '9e6', '4.5e6', '2.7e6', '1.08e6', ) self._bandwidth_tool_bar = Qt.QToolBar(self) self._bandwidth_tool_bar.addWidget(Qt.QLabel('bandwidth' + ": ")) self._bandwidth_combo_box = Qt.QComboBox() self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box) for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label) self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod( self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i))) self._bandwidth_callback(self.bandwidth) self._bandwidth_combo_box.currentIndexChanged.connect( lambda i: self.set_bandwidth(self._bandwidth_options[i])) self.top_layout.addWidget(self._bandwidth_tool_bar) self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args='', ), 1, -1) self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate) for i in xrange(1): self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq, i) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain, i) self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", i) self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, i) self.spectrum_latency_jsonfile_sink_0 = spectrum_latency.jsonfile_sink( num_ch, "/home/nae/Spectrum-Sensors/N210/Capture.N210/10-25-2016", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.loc", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.sys", "F37258", "12345", center_freq, bandwidth, meas_interval, 0, samp_rate, False) self.spectrum_latency_bin_statistics_0 = spectrum_latency.bin_statistics( num_ch, meas_period) self.spectrum_latency_bin_aggregator_0 = spectrum_latency.bin_aggregator( fft_size, num_ch, samp_rate, fft_size, center_freq, ActualBW, channel_bw, [0] * fft_size) self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (mywindow), True, 1) self._dest_host_options = ( "pwct1.ctl.nist.gov", "129.6.142.103", "129.6.142.181", "pwct5.ctl.nist.gov", ) self._dest_host_labels = ( 'pwct1', 'NEO_VM', 'pwct5Desktop', 'Pwct5', ) self._dest_host_tool_bar = Qt.QToolBar(self) self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host + ": ")) self._dest_host_combo_box = Qt.QComboBox() self._dest_host_tool_bar.addWidget(self._dest_host_combo_box) for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label) self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod( self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i))) self._dest_host_callback(self.dest_host) self._dest_host_combo_box.currentIndexChanged.connect( lambda i: self.set_dest_host(self._dest_host_options[i])) self.top_layout.addWidget(self._dest_host_tool_bar) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, num_ch, 30.0 + Vsq2W_dB) self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.spectrum_latency_bin_aggregator_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.spectrum_latency_jsonfile_sink_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.spectrum_latency_bin_aggregator_0, 0), (self.spectrum_latency_bin_statistics_0, 0)) self.connect((self.spectrum_latency_bin_statistics_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.uhd_rfnoc_streamer_radio_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self): gr.top_block.__init__(self, "rfnoc_rx_e3") ################################################## # Variables ################################################## self.vec_length = vec_length = 1 self.device3 = variable_uhd_device3_0 = ettus.device3( uhd.device_addr_t(",".join(('type=e3x0', "")))) self.server_port = server_port = 30000 self.server_address = server_address = "192.168.10.184" self.samp_rate = samp_rate = 1e6 self.rx_gain_A2 = rx_gain_A2 = 60 self.rf_freq = rf_freq = 871e6 self.decim_rate = decim_rate = 500e3 ################################################## # Blocks ################################################## self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_gr_complex, vec_length, 'tcp://*:9998', 100, False, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( (str(server_address), int(server_port)), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread( target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args='', ), 0, -1) self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate) self.uhd_rfnoc_streamer_radio_0.set_rx_freq(rf_freq, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain_A2, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_bandwidth(samp_rate, 0) if "RX2": self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", 0) self.uhd_rfnoc_streamer_radio_0.set_clock_source("internal") self.uhd_rfnoc_streamer_ddc_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", channels=range(1), args= "input_rate={},output_rate={},fullscale={},freq={},gr_vlen={},{}" .format( samp_rate, samp_rate, 1.0, 0, vec_length, "" if vec_length == 1 else "spp={}".format(vec_length)), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", channels=range(1), args="gr_vlen={},{}".format( vec_length, "" if vec_length == 1 else "spp={}".format(vec_length)), ), "DDC", -1, -1, ) for chan in xrange(1): self.uhd_rfnoc_streamer_ddc_0.set_arg("input_rate", float(samp_rate), chan) self.uhd_rfnoc_streamer_ddc_0.set_arg("output_rate", float(samp_rate), chan) self.uhd_rfnoc_streamer_ddc_0.set_arg("fullscale", 1.0, chan) self.uhd_rfnoc_streamer_ddc_0.set_arg("freq", 0, chan) ################################################## # Connections ################################################## self.connect((self.uhd_rfnoc_streamer_ddc_0, 0), (self.zeromq_push_sink_1, 0)) self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_ddc_0.get_block_id(), 0)
def __init__(self): gr.top_block.__init__(self, "Msod Sslsensor X310 Rfnoc") Qt.QWidget.__init__(self) self.setWindowTitle("Msod Sslsensor X310 Rfnoc") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "MSOD_SSLSensor_X310_RFNoC") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.fft_size = fft_size = 256 self.num_ch = num_ch = 50 self.hz_per_bin = hz_per_bin = samp_rate / fft_size self.bandwidth = bandwidth = 9e6 self.meas_interval = meas_interval = 1e-3 self.channel_bw = channel_bw = hz_per_bin * round(bandwidth / num_ch / hz_per_bin) self.device3 = variable_uhd_device3_0 = ettus.device3(uhd.device_addr_t( ",".join(("type=x300", "addr=usrp0")) )) self.rx_gain = rx_gain = 0 self.meas_period = meas_period = max(1, int(round(meas_interval * samp_rate / fft_size))) self.impedance = impedance = 50.0 self.dest_host = dest_host = "129.6.142.138" self.center_freq = center_freq = 724e6 self.ActualBW = ActualBW = channel_bw * num_ch ################################################## # Blocks ################################################## self._samp_rate_options = (10e6, 25e6, 12.5e6, 3.84e6, 5e5, ) self._samp_rate_labels = ("10e6", "25e6", "12.5e6", "3.84e6", "5e5", ) self._samp_rate_group_box = Qt.QGroupBox("samp_rate") self._samp_rate_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._samp_rate_button_group = variable_chooser_button_group() self._samp_rate_group_box.setLayout(self._samp_rate_box) for i, label in enumerate(self._samp_rate_labels): radio_button = Qt.QRadioButton(label) self._samp_rate_box.addWidget(radio_button) self._samp_rate_button_group.addButton(radio_button, i) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_button_group.buttonClicked[int].connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_group_box) self._rx_gain_range = Range(0, 31.5, 0.5, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "rx_gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._num_ch_options = (56, 50, 25, 15, 8, ) self._num_ch_labels = ("56", "50", "25", "15", "8", ) self._num_ch_group_box = Qt.QGroupBox("num_ch") self._num_ch_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._num_ch_button_group = variable_chooser_button_group() self._num_ch_group_box.setLayout(self._num_ch_box) for i, label in enumerate(self._num_ch_labels): radio_button = Qt.QRadioButton(label) self._num_ch_box.addWidget(radio_button) self._num_ch_button_group.addButton(radio_button, i) self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i))) self._num_ch_callback(self.num_ch) self._num_ch_button_group.buttonClicked[int].connect( lambda i: self.set_num_ch(self._num_ch_options[i])) self.top_layout.addWidget(self._num_ch_group_box) self._fft_size_options = (2048, 1024, 512, 256, 128, ) self._fft_size_labels = ("2048", "1024", "512", "256", "128", ) self._fft_size_tool_bar = Qt.QToolBar(self) self._fft_size_tool_bar.addWidget(Qt.QLabel("fft_size"+": ")) self._fft_size_combo_box = Qt.QComboBox() self._fft_size_tool_bar.addWidget(self._fft_size_combo_box) for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label) self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i))) self._fft_size_callback(self.fft_size) self._fft_size_combo_box.currentIndexChanged.connect( lambda i: self.set_fft_size(self._fft_size_options[i])) self.top_layout.addWidget(self._fft_size_tool_bar) self._center_freq_options = (709.01e6, 782e6, 724e6, ) self._center_freq_labels = ("AT&T", "Verizon", "ChannelEmulator", ) self._center_freq_tool_bar = Qt.QToolBar(self) self._center_freq_tool_bar.addWidget(Qt.QLabel("center_freq"+": ")) self._center_freq_combo_box = Qt.QComboBox() self._center_freq_tool_bar.addWidget(self._center_freq_combo_box) for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_layout.addWidget(self._center_freq_tool_bar) self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625), ), uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(fft_size, 0.984375, 0.015625), ), "VectorIIR", -1, -1, ) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", 0.984375) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta", 0.015625) self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args="spp=256", ), 0, -1 ) self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq) self.uhd_rfnoc_streamer_radio_0.set_rx_rate(samp_rate) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain) self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("TX/RX") self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True) self.uhd_rfnoc_streamer_logpwr_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format(num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format(num_ch, "" if num_ch == 1 else "spp={0}".format(num_ch)), ), "LogPwr", -1, -1, ) self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format(fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", otw_format="sc16", args="gr_vlen={0},{1}".format(fft_size, "" if fft_size == 1 else "spp={0}".format(fft_size)), ), "FIFO", -1, -1, ) self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="spp={},magnitude_out={}".format(256, "COMPLEX"), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "FFT", -1, -1, ) self.uhd_rfnoc_streamer_bin_aggr_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="" ), uhd.stream_args( cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "BinAggr", -1, -1, ) self.msod_sensor_jsonfile_sink_0 = msod_sensor.jsonfile_sink(num_ch, "/home/nae/capture/capture_X310/03_25_2016-002.dat", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.loc", "/raid/nae/pybombs_RFNoC/src/gr-msod_latency/examples/sensor_X310.sys", "X310", "NaN", center_freq, ActualBW, meas_interval, 0, samp_rate, False) self._dest_host_options = ("pwct1.ctl.nist.gov", "129.6.230.12", "129.6.142.181", "129.6.142.138", ) self._dest_host_labels = ("pwct1", "Naceur Laptop", "pwct5Desktop", "Pwct5", ) self._dest_host_tool_bar = Qt.QToolBar(self) self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host+": ")) self._dest_host_combo_box = Qt.QComboBox() self._dest_host_tool_bar.addWidget(self._dest_host_combo_box) for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label) self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i))) self._dest_host_callback(self.dest_host) self._dest_host_combo_box.currentIndexChanged.connect( lambda i: self.set_dest_host(self._dest_host_options[i])) self.top_layout.addWidget(self._dest_host_tool_bar) self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(num_ch) self._bandwidth_options = (10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, ) self._bandwidth_labels = ("10.08e6", "9e6", "4.5e6", "2.7e6", "1.08e6", ) self._bandwidth_tool_bar = Qt.QToolBar(self) self._bandwidth_tool_bar.addWidget(Qt.QLabel("bandwidth"+": ")) self._bandwidth_combo_box = Qt.QComboBox() self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box) for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label) self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i))) self._bandwidth_callback(self.bandwidth) self._bandwidth_combo_box.currentIndexChanged.connect( lambda i: self.set_bandwidth(self._bandwidth_options[i])) self.top_layout.addWidget(self._bandwidth_tool_bar) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.msod_sensor_jsonfile_sink_0, 0)) self.connect((self.uhd_rfnoc_streamer_logpwr_0, 0), (self.blocks_complex_to_mag_0, 0)) self.device3.connect(self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0, self.uhd_rfnoc_streamer_logpwr_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0, self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0, self.uhd_rfnoc_streamer_bin_aggr_0.get_block_id(), 0)
def __init__(self, args1, args2): gr.top_block.__init__(self) ############################## # TRANSMIT CHAIN ############################## print "\nTRANSMIT CHAIN" ##USRP transmits repeating file generated in MATLAB #self.tx_src = blocks.file_source(gr.sizeof_gr_complex, "iq_in.dat", True) #USRP transmits a repeating vector generated here... tx_list = [ 0.2363 + 0.0741j, 0.0733 - 0.2865j, -0.1035 - 0.2663j, -0.0853 + 0.1909j, -0.0736 + 0.2699j, 0.0773 + 0.1481j, -0.0336 + 0.2079j, -0.0644 - 0.2244j, 0.0396 + 0.2822j, -0.0595 - 0.2416j, 0.1379 + 0.2658j, -0.0449 - 0.2539j, 0.0593 + 0.2946j, 0.0221 - 0.0113j, -0.1303 + 0.2762j, -0.1351 - 0.2598j, -0.0275 - 0.2617j, 0.2157 + 0.1021j, 0.0332 - 0.0383j, -0.1369 - 0.2680j ] self.vec_tx_src = blocks.vector_source_c(tuple(tx_list), True, SIGNAL_LEN, []) self.tx_src = blocks.vector_to_stream(gr.sizeof_gr_complex, SIGNAL_LEN) #Find USRP with device characteristics specified by args1 d1 = uhd.find_devices(uhd.device_addr(args1)) uhd_type1 = d1[0].get('type') print "\nFound '%s' at args '%s'" % \ (uhd_type1, args1) stream_args = uhd.stream_args('fc32') self.u_tx = uhd.usrp_sink(device_addr=args1, stream_args=stream_args) self.u_tx.set_samp_rate(SAMPLE_RATE) self.u_tx.set_clock_source("external") self.center_freq = END_FREQ - STEP_FREQ self.tr = uhd.tune_request(self.center_freq) self.tr.args = uhd.device_addr_t("mode_n=integer") self.u_tx.set_center_freq(self.tr) self.u_tx.set_bandwidth(SAMPLE_RATE * 1.5) # Get dboard gain range and select maximum tx_gain_range = self.u_tx.get_gain_range() tx_gain = tx_gain_range.stop() self.u_tx.set_gain(tx_gain - 9) self.connect(self.vec_tx_src, self.tx_src, self.u_tx) ############################## # RECEIVE CHAIN ############################## print "\nRECEIVE CHAIN" #USRP logs IQ data to file #This PMT dictionary stuff is stupid, however it's required otherwise the header will become corrupted... key = pmt.intern("rx_freq") val = pmt.from_double(0) extras = pmt.make_dict() extras = pmt.dict_add(extras, key, val) extras = pmt.serialize_str(extras) self.tag_debug = None self.u_rxs = [] for usrp_addr in args2.split(","): kv = usrp_addr.split("=") rx_dst = blocks.file_meta_sink( gr.sizeof_gr_complex * SIGNAL_LEN, "iq_out_{}.dat".format(kv[1]), SAMPLE_RATE, extra_dict=extras) #, detached_header=True) #rx_dst = blocks.file_sink(gr.sizeof_gr_complex*SIGNAL_LEN, "iq_out.dat") # Accumulate repeating sequences using custom block rx_accum = slocalization.accumulator_vcvc(SIGNAL_LEN, int(1e3)) #Find USRP with device characteristics specified by args1 d2 = uhd.find_devices(uhd.device_addr(usrp_addr)) uhd_type2 = d2[0].get('type') print "\nFound '%s' at args '%s'" % \ (uhd_type2, usrp_addr) u_rx = uhd.usrp_source(device_addr=usrp_addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) u_rx.set_samp_rate(SAMPLE_RATE) u_rx.set_bandwidth(SAMPLE_RATE * 1.5) u_rx.set_clock_source("external") u_rx.set_center_freq(self.tr) self.u_rxs.append(u_rx) # Get dboard gain range and select maximum rx_gain_range = u_rx.get_gain_range() rx_gain = rx_gain_range.stop() u_rx.set_gain(rx_gain, 0) # Convert stream to vector s_to_v = blocks.stream_to_vector(gr.sizeof_gr_complex, SIGNAL_LEN) self.connect(u_rx, s_to_v, rx_accum, rx_dst) #self.connect (u_rx, s_to_v, rx_dst) if not self.tag_debug: # DEBUG: Monitor incoming tags... self.tag_debug = blocks.tag_debug( gr.sizeof_gr_complex * SIGNAL_LEN, "tag_debugger", "") self.connect(rx_accum, self.tag_debug) # Synchronize both USRPs' timebases u_rx.set_time_now(uhd.time_spec(0.0)) # Synchronize both USRPs' timebases self.u_tx.set_time_now(uhd.time_spec(0.0))
def __init__(self, istx, ismimo, args, bandwidth, freq=None, lo_offset=None, gain=None, spec=None, antenna=None, clock_source=None, time_source=None): # check the USRP model name print "Assuming only one type of USRP. Checking USRP model..." usrp = uhd.usrp_source(device_addr=uhd.device_addr_t(''), stream_args=uhd.stream_args('fc32')) self._usrp_model = usrp.get_usrp_info().get("mboard_id") print "Using USRP model:", self._usrp_model del (usrp) if (istx): if self._usrp_model == 'USRP1': # load special FPGA bitstream to get a flat frequency response print "Loading special FPGA bitstream for USRP1 Tx to obtain flat frequency response" UHD_DIR = os.environ.get("UHD_DIR") if UHD_DIR != None and UHD_DIR != "": args = uhd.device_addr_t( 'fpga=' + UHD_DIR + 'share/uhd/images/std_1rxhb_1txhb.rbf') else: args = uhd.device_addr_t( 'fpga=/usr/share/uhd/images/std_1rxhb_1txhb.rbf') self.u = uhd.usrp_sink(device_addr=args, stream_args=uhd.stream_args('fc32')) else: if (ismimo): self.u = uhd.usrp_source( device_addr=" addr0=192.168.10.2, addr1=192.168.10.3", stream_args=uhd.stream_args('fc32', channels=range(2))) else: self.u = uhd.usrp_source(device_addr=args, stream_args=uhd.stream_args('fc32')) #Make adjustments for USRP1 halfband filters if istx and self._usrp_model == 'USRP1': bandwidth = (bandwidth / 2.0) # write the other parameters to member variables self._istx = istx self._args = args self._ant = antenna self._ismimo = ismimo self._spec = spec self._gain = self.set_gain(gain) self._lo_offset = lo_offset self._rate = self.set_sample_rate(bandwidth) self._freq = self.set_freq(freq, lo_offset) self._clock_source = clock_source self._time_source = time_source # Set clock source to external. if (clock_source): print "clock_source: ", clock_source self.u.set_clock_source(clock_source, 0) if (time_source): print "time_source: ", time_source self.u.set_time_source(time_source, 0) # Set the subdevice spec if (spec): self.u.set_subdev_spec(spec, 0) # Set the antenna if (antenna): self.u.set_antenna(antenna, 0)
def __init__(self): gr.top_block.__init__(self, "Rfnoc Fft Vectoriir") ################################################## # Variables ################################################## self.alpha = alpha = 0.986 self.seconds = seconds = 5 self.samp_rate = samp_rate = 40e6 self.rf_gain = rf_gain = 0 self.num_points = num_points = 512 self.hard_coded_sample_count = hard_coded_sample_count = 2883584 self.freq = freq = 2440e6 self.device3 = device3 = ettus.device3(uhd.device_addr_t( ",".join(('type=e3x0', "fpga=/home/root/usrp_e310_fpga_RFNOC_sg3.bit")) )) self.decim_rate = decim_rate = 18 self.beta = beta = 1-alpha ################################################## # Blocks ################################################## self.uhd_rfnoc_streamer_vector_iir_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(num_points, alpha, beta), ), uhd.stream_args( # TX Stream Args cpu_format="fc32", otw_format="sc16", args="spp={},alpha={},beta={}".format(num_points, alpha, beta), ), "VectorIIR", -1, -1, ) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("alpha", alpha) self.uhd_rfnoc_streamer_vector_iir_0.set_arg("beta", beta) self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args='spp=512', ), 0, -1 ) self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate) self.uhd_rfnoc_streamer_radio_0.set_rx_freq(freq, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rf_gain, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, 0) self.uhd_rfnoc_streamer_radio_0.set_rx_bandwidth(40e6, 0) if "RX2": self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", 0) self.uhd_rfnoc_streamer_radio_0.set_clock_source("internal") self.uhd_rfnoc_streamer_keep_one_in_n_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="n="+str(decim_rate), ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "KeepOneInN", -1, -1, ) self.uhd_rfnoc_streamer_fft_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="spp={}".format(num_points), # Need to set the FFT size here, or it won't go into the GR IO signature ), uhd.stream_args( # RX Stream Args cpu_format="fc32", # TODO: This must be made an option otw_format="sc16", args="", ), "FFT", -1, -1, ) self.uhd_rfnoc_streamer_fft_0.set_arg("direction", "forward") self.uhd_rfnoc_streamer_fft_0.set_arg("scaling", 1000) self.uhd_rfnoc_streamer_fft_0.set_arg("shift", "normal") self.uhd_rfnoc_streamer_fft_0.set_arg("magnitude_out", "COMPLEX") self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, hard_coded_sample_count) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, '/home/root/test_data', False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.uhd_rfnoc_streamer_keep_one_in_n_0, 0), (self.blocks_head_0, 0)) self.device3.connect(self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0, self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_radio_0.get_block_id(), 0, self.uhd_rfnoc_streamer_fft_0.get_block_id(), 0) self.device3.connect(self.uhd_rfnoc_streamer_vector_iir_0.get_block_id(), 0, self.uhd_rfnoc_streamer_keep_one_in_n_0.get_block_id(), 0)
def __init__(self): gr.top_block.__init__(self, "Msod Sslsensor N210") Qt.QWidget.__init__(self) self.setWindowTitle("Msod Sslsensor N210") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "MSOD_SSLSensor_N210") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 12.5e6 self.fft_size = fft_size = 625 self.num_ch = num_ch = 56 self.mywindow = mywindow = window.blackmanharris(fft_size) self.hz_per_bin = hz_per_bin = samp_rate / fft_size self.bandwidth = bandwidth = 10.08e6 self.window_power = window_power = sum(map(lambda x: x*x, mywindow)) self.meas_interval = meas_interval = 1e-3 self.impedance = impedance = 50.0 self.channel_bw = channel_bw = hz_per_bin * round(bandwidth / num_ch / hz_per_bin) self.device3 = variable_uhd_device3_0 = ettus.device3(uhd.device_addr_t( ",".join(('type=x300, addr=usrp02', "")) )) self.rx_gain = rx_gain = 0 self.meas_period = meas_period = max(1, int(round(meas_interval * samp_rate / fft_size))) self.dest_host = dest_host = "129.6.142.103" self.center_freq = center_freq = 724e6 self.Vsq2W_dB = Vsq2W_dB = -10.0 * math.log10(fft_size * int(window_power) * impedance) self.ActualBW = ActualBW = channel_bw * num_ch ################################################## # Blocks ################################################## self._samp_rate_options = (12.5e6, 15.36e6, 7.68e6, 3.84e6, 1.92e6, ) self._samp_rate_labels = ('12.5e6', '15.36e6', '7.68e6', '3.84e6', '1.92e6', ) self._samp_rate_group_box = Qt.QGroupBox('samp_rate') self._samp_rate_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._samp_rate_button_group = variable_chooser_button_group() self._samp_rate_group_box.setLayout(self._samp_rate_box) for i, label in enumerate(self._samp_rate_labels): radio_button = Qt.QRadioButton(label) self._samp_rate_box.addWidget(radio_button) self._samp_rate_button_group.addButton(radio_button, i) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_button_group.buttonClicked[int].connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_group_box) self._rx_gain_range = Range(0, 31.5, 0.5, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'rx_gain', "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self._num_ch_options = (56, 50, 25, 15, 8, ) self._num_ch_labels = ('56', '50', '25', '15', '8', ) self._num_ch_group_box = Qt.QGroupBox('num_ch') self._num_ch_box = Qt.QVBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._num_ch_button_group = variable_chooser_button_group() self._num_ch_group_box.setLayout(self._num_ch_box) for i, label in enumerate(self._num_ch_labels): radio_button = Qt.QRadioButton(label) self._num_ch_box.addWidget(radio_button) self._num_ch_button_group.addButton(radio_button, i) self._num_ch_callback = lambda i: Qt.QMetaObject.invokeMethod(self._num_ch_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._num_ch_options.index(i))) self._num_ch_callback(self.num_ch) self._num_ch_button_group.buttonClicked[int].connect( lambda i: self.set_num_ch(self._num_ch_options[i])) self.top_layout.addWidget(self._num_ch_group_box) self._fft_size_options = (625, 1024, 512, 256, 128, ) self._fft_size_labels = ('625', '1024', '512', '256', '128', ) self._fft_size_tool_bar = Qt.QToolBar(self) self._fft_size_tool_bar.addWidget(Qt.QLabel('fft_size'+": ")) self._fft_size_combo_box = Qt.QComboBox() self._fft_size_tool_bar.addWidget(self._fft_size_combo_box) for label in self._fft_size_labels: self._fft_size_combo_box.addItem(label) self._fft_size_callback = lambda i: Qt.QMetaObject.invokeMethod(self._fft_size_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._fft_size_options.index(i))) self._fft_size_callback(self.fft_size) self._fft_size_combo_box.currentIndexChanged.connect( lambda i: self.set_fft_size(self._fft_size_options[i])) self.top_layout.addWidget(self._fft_size_tool_bar) self._center_freq_options = (709.01e6, 782e6, 724e6, ) self._center_freq_labels = ('AT&T', 'Verizon', 'ChannelEmulator', ) self._center_freq_tool_bar = Qt.QToolBar(self) self._center_freq_tool_bar.addWidget(Qt.QLabel('center_freq'+": ")) self._center_freq_combo_box = Qt.QComboBox() self._center_freq_tool_bar.addWidget(self._center_freq_combo_box) for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label) self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i))) self._center_freq_callback(self.center_freq) self._center_freq_combo_box.currentIndexChanged.connect( lambda i: self.set_center_freq(self._center_freq_options[i])) self.top_layout.addWidget(self._center_freq_tool_bar) self._bandwidth_options = (10.08e6, 9e6, 4.5e6, 2.7e6, 1.08e6, ) self._bandwidth_labels = ('10.08e6', '9e6', '4.5e6', '2.7e6', '1.08e6', ) self._bandwidth_tool_bar = Qt.QToolBar(self) self._bandwidth_tool_bar.addWidget(Qt.QLabel('bandwidth'+": ")) self._bandwidth_combo_box = Qt.QComboBox() self._bandwidth_tool_bar.addWidget(self._bandwidth_combo_box) for label in self._bandwidth_labels: self._bandwidth_combo_box.addItem(label) self._bandwidth_callback = lambda i: Qt.QMetaObject.invokeMethod(self._bandwidth_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._bandwidth_options.index(i))) self._bandwidth_callback(self.bandwidth) self._bandwidth_combo_box.currentIndexChanged.connect( lambda i: self.set_bandwidth(self._bandwidth_options[i])) self.top_layout.addWidget(self._bandwidth_tool_bar) self.uhd_rfnoc_streamer_radio_0 = ettus.rfnoc_radio( self.device3, uhd.stream_args( # Tx Stream Args cpu_format="fc32", otw_format="sc16", args="", # empty ), uhd.stream_args( # Rx Stream Args cpu_format="fc32", otw_format="sc16", args='', ), 1, -1 ) self.uhd_rfnoc_streamer_radio_0.set_rate(samp_rate) for i in xrange(1): self.uhd_rfnoc_streamer_radio_0.set_rx_freq(center_freq, i) self.uhd_rfnoc_streamer_radio_0.set_rx_gain(rx_gain, i) self.uhd_rfnoc_streamer_radio_0.set_rx_antenna("RX2", i) self.uhd_rfnoc_streamer_radio_0.set_rx_dc_offset(True, i) self.spectrum_latency_jsonfile_sink_0 = spectrum_latency.jsonfile_sink(num_ch, "/home/nae/Spectrum-Sensors/N210/Capture.N210/10-25-2016", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.loc", "/raid/nae/gnuradio/src/gr-spectrum_latency/examples/utils/sensor.sys", "F37258", "12345", center_freq, bandwidth, meas_interval, 0, samp_rate, False) self.spectrum_latency_bin_statistics_0 = spectrum_latency.bin_statistics(num_ch, meas_period) self.spectrum_latency_bin_aggregator_0 = spectrum_latency.bin_aggregator(fft_size, num_ch, samp_rate, fft_size, center_freq, ActualBW, channel_bw, [0] * fft_size) self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (mywindow), True, 1) self._dest_host_options = ("pwct1.ctl.nist.gov", "129.6.142.103", "129.6.142.181", "pwct5.ctl.nist.gov", ) self._dest_host_labels = ('pwct1', 'NEO_VM', 'pwct5Desktop', 'Pwct5', ) self._dest_host_tool_bar = Qt.QToolBar(self) self._dest_host_tool_bar.addWidget(Qt.QLabel(dest_host+": ")) self._dest_host_combo_box = Qt.QComboBox() self._dest_host_tool_bar.addWidget(self._dest_host_combo_box) for label in self._dest_host_labels: self._dest_host_combo_box.addItem(label) self._dest_host_callback = lambda i: Qt.QMetaObject.invokeMethod(self._dest_host_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._dest_host_options.index(i))) self._dest_host_callback(self.dest_host) self._dest_host_combo_box.currentIndexChanged.connect( lambda i: self.set_dest_host(self._dest_host_options[i])) self.top_layout.addWidget(self._dest_host_tool_bar) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, num_ch, 30.0 + Vsq2W_dB) self.blocks_float_to_char_0 = blocks.float_to_char(num_ch, 1.0) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.spectrum_latency_bin_aggregator_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.spectrum_latency_jsonfile_sink_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.spectrum_latency_bin_aggregator_0, 0), (self.spectrum_latency_bin_statistics_0, 0)) self.connect((self.spectrum_latency_bin_statistics_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.uhd_rfnoc_streamer_radio_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self): gr.top_block.__init__(self, "Latencytest") ################################################## # Variables ################################################## self.spp = spp = 4 self.vlb = vlb = spp * 4 self.device3 = variable_uhd_device3_0 = ettus.device3( uhd.device_addr_t(",".join(('type=x300', 'args')))) self.samp_rate = samp_rate = 500000 ################################################## # Blocks ################################################## self.uhd_rfnoc_streamer_fifo_0 = ettus.rfnoc_generic( self.device3, uhd.stream_args( # TX Stream Args cpu_format="u8", otw_format="u8", args="gr_vlen={0},{1}".format( vlb, "" if vlb == 1 else "spp={0}".format(vlb)), ), uhd.stream_args( # RX Stream Args cpu_format="u8", otw_format="u8", args="gr_vlen={0},{1}".format( vlb, "" if vlb == 1 else "spp={0}".format(vlb)), ), "FIFO", -1, -1, ) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_int * spp, samp_rate, True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_int * spp, '/home/vivado/rfnoc/src/rfnoc-Kwan/test_in.bin', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_int * spp, '/home/vivado/rfnoc/src/rfnoc-Kwan/out.bin', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_copy_0 = blocks.copy(gr.sizeof_int * spp) self.blocks_copy_0.set_enabled(True) self.Kwan_latencytest_0 = Kwan.latencytest( self.device3, uhd.stream_args( # TX Stream Args cpu_format="u8", otw_format="u8", args="gr_vlen={0},{1}".format( vlb, "" if vlb == 1 else "spp={0}".format(vlb)), ), uhd.stream_args( # RX Stream Args cpu_format="u8", otw_format="u8", args="gr_vlen={0},{1}".format( vlb, "" if vlb == 1 else "spp={0}".format(vlb)), ), -1, -1) ################################################## # Connections ################################################## self.connect((self.blocks_copy_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.uhd_rfnoc_streamer_fifo_0, 0)) self.connect((self.Kwan_latencytest_0, 0), (self.blocks_copy_0, 0)) self.device3.connect(self.uhd_rfnoc_streamer_fifo_0.get_block_id(), 0, self.Kwan_latencytest_0.get_block_id(), 0)