def __init__(self, rx_gain=50, tx_gain=5): gr.top_block.__init__(self, "Electosense") ################################################## # Parameters ################################################## self.rx_gain = rx_gain self.tx_gain = tx_gain ################################################## # Variables ################################################## self.sensorid = sensorid = 123456 self.samp_rate = samp_rate = 1e6 self.fft_size = fft_size = 512 self.cfreq = cfreq = 100e6 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(cfreq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(rx_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.electrosense_rpi_gpufft_0 = electrosense.rpi_gpufft( 512, True, True, 16) self.electrosense_discard_samples_0 = electrosense.discard_samples( 100, int(cfreq), pmt.intern("burst_len"), False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex * fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_vector_0, 0), (self.electrosense_rpi_gpufft_0, 0)) self.connect((self.electrosense_discard_samples_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.electrosense_rpi_gpufft_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.electrosense_discard_samples_0, 0))
def __init__(self, end_f=2000e6, start_f=50e6): gr.top_block.__init__(self, "Electosense") Qt.QWidget.__init__(self) self.setWindowTitle("Electosense") qtgui.util.check_set_qss() 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", "electrosense_final") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.end_f = end_f self.start_f = start_f ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e6 self.prober = prober = 1 self.hop_mode = hop_mode = 0 self.tune_delay = tune_delay = 20e-3 self.sensorid = sensorid = 123456 self.rfgain = rfgain = 40 self.ppm = ppm = 0 self.navg_vectors = navg_vectors = 50 self.fft_size = fft_size = 4096 self.cfreq = cfreq = scanning.step(start_f, end_f, samp_rate / 1.5, prober, hop_mode, 0.8, 0.8) self.alpha = alpha = 0.75 ################################################## # Blocks ################################################## self.vecprobe = blocks.probe_signal_vf(fft_size) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(('addr=192.168.10.2', "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_center_freq(cfreq, 0) self.uhd_usrp_source_0.set_gain(35, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec()) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( alpha, fft_size) def _prober_probe(): while True: val = self.vecprobe.level() try: self.set_prober(val) except AttributeError: pass time.sleep(1.0 / (1 / (tune_delay + (1 / samp_rate * fft_size * navg_vectors)))) _prober_thread = threading.Thread(target=_prober_probe) _prober_thread.daemon = True _prober_thread.start() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, window.blackmanharris(fft_size), True, 1) self.electrosense_variable_updater_0 = electrosense.variable_updater self.electrosense_variable_updater_0.register_instance(self) self.electrosense_sensor_sink_0 = electrosense.sensor_sink( 'collector.electrosense.org', 5000, fft_size, "float32", '/home/rsreeraj/gnu_work/gr-electrosense/python/rtl-spec.avsc', '/home/rsreeraj/gnu_work/gr-electrosense/python/sensor_cert/Sensor-SSL-SK.pem', '/home/rsreeraj/gnu_work/gr-electrosense/python/sensor_cert/Sensor-SSL-Cert.pem', sensorid, 0, 2, fft_size, int(3 / alpha), 0.1, int(samp_rate / fft_size), int(cfreq), rfgain) self.electrosense_mqtt_client_0 = electrosense.mqtt_client( '127.0.0.1', 1883, 'electrosense', '', '', '') self.electrosense_discard_samples_0 = electrosense.discard_samples( int(tune_delay * samp_rate), int(cfreq), pmt.intern("burst_len"), False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * fft_size, navg_vectors) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_size) ################################################## # Connections ################################################## self.msg_connect((self.electrosense_mqtt_client_0, 'out'), (self.electrosense_variable_updater_0, 'in')) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.electrosense_sensor_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.vecprobe, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.electrosense_discard_samples_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.electrosense_discard_samples_0, 0))
def __init__(self, end_f=500e6, parameter_0=0, start_f=50e6): gr.top_block.__init__(self, "Electosense") Qt.QWidget.__init__(self) self.setWindowTitle("Electosense") qtgui.util.check_set_qss() 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", "electrosense_hopping") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.end_f = end_f self.parameter_0 = parameter_0 self.start_f = start_f ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.prober = prober = 1 self.hop_mode = hop_mode = 1 self.variable_0 = variable_0 = 0 self.tune_delay = tune_delay = 50e-3 self.sensorid = sensorid = 123456 self.rfgain = rfgain = 40 self.ppm = ppm = 0 self.navg_vectors = navg_vectors = 100 self.fft_size = fft_size = 512 self.cfreq = cfreq = scanning.step(start_f, end_f, samp_rate / 1.5, prober, hop_mode, 0.8, 0.8) self.alpha = alpha = 0.75 ################################################## # Blocks ################################################## self.vecprobe = blocks.probe_signal_vf(fft_size) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( alpha, fft_size) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(cfreq, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(rfgain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( fft_size, 0, 1.0, "x-Axis", "y-Axis", "", 1 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-140, 10) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(False) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win) def _prober_probe(): while True: val = self.vecprobe.level() try: self.set_prober(val) except AttributeError: pass time.sleep(1.0 / (1 / (tune_delay + (1 / samp_rate * fft_size * navg_vectors)))) _prober_thread = threading.Thread(target=_prober_probe) _prober_thread.daemon = True _prober_thread.start() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, window.blackmanharris(fft_size), True, 1) self.electrosense_discard_samples_0 = electrosense.discard_samples( int(tune_delay * samp_rate), int(cfreq), pmt.intern("burst_len"), False) 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(1, fft_size, 0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * fft_size, navg_vectors) 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.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.vecprobe, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.electrosense_discard_samples_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.electrosense_discard_samples_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))
def __init__(self, end_f=500e6, start_f=50e6): gr.top_block.__init__(self, "Electosense") ################################################## # Parameters ################################################## self.end_f = end_f self.start_f = start_f ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.prober = prober = 1 self.hop_mode = hop_mode = 2 self.tune_delay = tune_delay = 50e-3 self.sensorid = sensorid = 123456 self.rfgain = rfgain = 40 self.ppm = ppm = 0 self.navg_vectors = navg_vectors = 100 self.fft_size = fft_size = 512 self.cfreq = cfreq = scanning.step(start_f, end_f, samp_rate / 1.5, prober, hop_mode, 0.8, 0.8) self.alpha = alpha = 0.75 ################################################## # Blocks ################################################## self.vecprobe = blocks.probe_signal_vf(fft_size) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( alpha, fft_size) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(cfreq, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(rfgain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) def _prober_probe(): while True: val = self.vecprobe.level() try: self.set_prober(val) except AttributeError: pass time.sleep(1.0 / (1 / (tune_delay + (1 / samp_rate * fft_size * navg_vectors)))) _prober_thread = threading.Thread(target=_prober_probe) _prober_thread.daemon = True _prober_thread.start() self.fft_vxx_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 1) self.electrosense_discard_samples_0 = electrosense.discard_samples( int(tune_delay * samp_rate), int(cfreq), pmt.intern("burst_len"), False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, fft_size) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * fft_size, navg_vectors) 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.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.vecprobe, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.electrosense_discard_samples_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.electrosense_discard_samples_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0))