def __init__(self): gr.top_block.__init__(self, "NFM SCANNER") Qt.QWidget.__init__(self) self.setWindowTitle("NFM SCANNER") 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", "scanner") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freqd = freqd = 0 self.stop_scan_a = stop_scan_a = 0 self.freq_set = freq_set = freqd self.variable_qtgui_label_0 = variable_qtgui_label_0 = stop_scan_a self.sql = sql = -50 self.samp_rate = samp_rate = 32000 self.s_rate = s_rate = 2 self.r_rate = r_rate = 240000 self.hold_scan = hold_scan = 0 self.gain = gain = 30 self.frequency = frequency = freq_set / 1000000 ################################################## # Blocks ################################################## self.stop_scan = blocks.probe_signal_f() def _stop_scan_a_probe(): while True: val = self.stop_scan.level() try: self.set_stop_scan_a(val) except AttributeError: pass time.sleep(1.0 / (100)) _stop_scan_a_thread = threading.Thread(target=_stop_scan_a_probe) _stop_scan_a_thread.daemon = True _stop_scan_a_thread.start() self._sql_range = Range(-100, 0, 1, -50, 50) self._sql_win = RangeWidget(self._sql_range, self.set_sql, "squelch", "dial", float) self.top_layout.addWidget(self._sql_win) self._s_rate_options = ( .5, 1, 2, 5, 10, ) self._s_rate_labels = ( ".5Hz", "1Hz", "2Hz", "5Hz", "10Hz", ) self._s_rate_tool_bar = Qt.QToolBar(self) self._s_rate_tool_bar.addWidget(Qt.QLabel("SCAN RATE" + ": ")) self._s_rate_combo_box = Qt.QComboBox() self._s_rate_tool_bar.addWidget(self._s_rate_combo_box) for label in self._s_rate_labels: self._s_rate_combo_box.addItem(label) self._s_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._s_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._s_rate_options.index(i))) self._s_rate_callback(self.s_rate) self._s_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_s_rate(self._s_rate_options[i])) self.top_layout.addWidget(self._s_rate_tool_bar) _hold_scan_check_box = Qt.QCheckBox("hold_scan") self._hold_scan_choices = {True: 1, False: 0} self._hold_scan_choices_inv = dict( (v, k) for k, v in self._hold_scan_choices.iteritems()) self._hold_scan_callback = lambda i: Qt.QMetaObject.invokeMethod( _hold_scan_check_box, "setChecked", Qt.Q_ARG("bool", self._hold_scan_choices_inv[i])) self._hold_scan_callback(self.hold_scan) _hold_scan_check_box.stateChanged.connect( lambda i: self.set_hold_scan(self._hold_scan_choices[bool(i)])) self.top_layout.addWidget(_hold_scan_check_box) self._gain_range = Range(0, 50, 1, 30, 25) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "GAIN", "dial", float) self.top_layout.addWidget(self._gain_win) self.freqb = blocks.probe_signal_f() self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel("scan" + ": ")) self._variable_qtgui_label_0_label = Qt.QLabel( str( self._variable_qtgui_label_0_formatter( self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget( self._variable_qtgui_label_0_label) self.top_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self.valve = grc_blks2.valve(item_size=gr.sizeof_float * 1, open=bool(stop_scan_a or hold_scan)) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(r_rate) self.rtlsdr_source_0.set_center_freq(freq_set - 100000, 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(0, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(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(r_rate, 0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq_set, #fc r_rate, #bw "", #name True, #plotfreq True, #plotwaterfall False, #plottime False, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.low_pass_filter_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, r_rate, 7500, 5000, firdes.WIN_HAMMING, 6.76)) self._frequency_tool_bar = Qt.QToolBar(self) if None: self._frequency_formatter = None else: self._frequency_formatter = lambda x: x self._frequency_tool_bar.addWidget(Qt.QLabel("frequency" + ": ")) self._frequency_label = Qt.QLabel( str(self._frequency_formatter(self.frequency))) self._frequency_tool_bar.addWidget(self._frequency_label) self.top_layout.addWidget(self._frequency_tool_bar) def _freqd_probe(): while True: val = self.freqb.level() try: self.set_freqd(val) except AttributeError: pass time.sleep(1.0 / (s_rate)) _freqd_thread = threading.Thread(target=_freqd_probe) _freqd_thread.daemon = True _freqd_thread.start() self.freqa = blocks.file_source( gr.sizeof_float * 1, "/home/jed/radio/PROJECTS/scanner/freqtest.dat", True) self.blocks_threshold_ff_0 = blocks.threshold_ff( 0.0000000001, .0001, 0) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 10) self.blocks_add_xx_0 = blocks.add_vff(1) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_sig_source_x_0 = analog.sig_source_c( r_rate, analog.GR_COS_WAVE, -100000, 1, 0) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( sql, 1e-3, 5, False) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=48000, quad_rate=r_rate / 5, tau=75e-6, max_dev=5.0e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.analog_nbfm_rx_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_delay_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_threshold_ff_0, 0), (self.stop_scan, 0)) self.connect((self.freqa, 0), (self.valve, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.valve, 0), (self.freqb, 0))
def __init__(self): gr.top_block.__init__(self, "Calibration Example") Qt.QWidget.__init__(self) self.setWindowTitle("Calibration Example") 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", "calibration_example_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.speed_of_light = speed_of_light = 299792458 self.antenna_spacing = antenna_spacing = 0.06 self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1 self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 1 self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1 self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0 self.samp_rate = samp_rate = 100000000/256 self.gain_rx = gain_rx = 0 self.center_freq = center_freq = speed_of_light/(2*antenna_spacing) self.cal_freq = cal_freq = 1024 ################################################## # Blocks ################################################## self._variable_qtgui_chooser_0_1_1_options = (1, 0, ) self._variable_qtgui_chooser_0_1_1_labels = ("Not Started", "Start Save", ) self._variable_qtgui_chooser_0_1_1_group_box = Qt.QGroupBox("Trigger Data Save") self._variable_qtgui_chooser_0_1_1_box = Qt.QHBoxLayout() 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._variable_qtgui_chooser_0_1_1_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_1_1_group_box.setLayout(self._variable_qtgui_chooser_0_1_1_box) for i, label in enumerate(self._variable_qtgui_chooser_0_1_1_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_1_1_box.addWidget(radio_button) self._variable_qtgui_chooser_0_1_1_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_1_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_1_options.index(i))) self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1) self._variable_qtgui_chooser_0_1_1_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_1_group_box) self._variable_qtgui_chooser_0_1_0_options = (1, 0, ) self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", ) self._variable_qtgui_chooser_0_1_0_tool_bar = Qt.QToolBar(self) self._variable_qtgui_chooser_0_1_0_tool_bar.addWidget(Qt.QLabel("Sync System"+": ")) self._variable_qtgui_chooser_0_1_0_combo_box = Qt.QComboBox() self._variable_qtgui_chooser_0_1_0_tool_bar.addWidget(self._variable_qtgui_chooser_0_1_0_combo_box) for label in self._variable_qtgui_chooser_0_1_0_labels: self._variable_qtgui_chooser_0_1_0_combo_box.addItem(label) self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i))) self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0) self._variable_qtgui_chooser_0_1_0_combo_box.currentIndexChanged.connect( lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_tool_bar) self._variable_qtgui_chooser_0_0_0_options = (0, 1, ) self._variable_qtgui_chooser_0_0_0_labels = ("Enable", "Disable", ) self._variable_qtgui_chooser_0_0_0_group_box = Qt.QGroupBox("Transmitter Enable") self._variable_qtgui_chooser_0_0_0_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._variable_qtgui_chooser_0_0_0_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_0_box) for i, label in enumerate(self._variable_qtgui_chooser_0_0_0_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_0_0_box.addWidget(radio_button) self._variable_qtgui_chooser_0_0_0_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_0_options.index(i))) self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0) self._variable_qtgui_chooser_0_0_0_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_0_group_box) self._variable_qtgui_chooser_0_0_options = (0, 1, ) self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", ) self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable") self._variable_qtgui_chooser_0_0_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._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box) for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_0_box.addWidget(radio_button) self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i))) self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0) self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box) self.wifius_find_scale_factor_0_0 = wifius.find_scale_factor(samp_rate,cal_freq) self.wifius_find_scale_factor_0 = wifius.find_scale_factor(samp_rate,cal_freq) self.wifius_divide_by_message_0_0 = wifius.divide_by_message() self.wifius_divide_by_message_0 = wifius.divide_by_message() self.wifius_blocker_0 = wifius.blocker(True) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr0=192.168.20.2,addr1=192.168.50.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0_0.set_clock_source("external", 0) self.uhd_usrp_source_0_0.set_time_source("external", 0) self.uhd_usrp_source_0_0.set_clock_source("external", 1) self.uhd_usrp_source_0_0.set_time_source("external", 1) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_source_0_0.set_gain(gain_rx, 0) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1) self.uhd_usrp_source_0_0.set_gain(gain_rx, 1) self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.90.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0_0.set_gain(30, 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.40.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0) self.uhd_usrp_sink_0_0.set_time_source("mimo", 0) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0.set_gain(10, 0) self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Input") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Post Gain Correct") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Post Phase Correct") self.top_layout.addWidget(self.tab) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(True) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_AUTO, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.delay_correct_hier_0 = delay_correct_hier( cal_tone_freq=cal_freq, mu=0.001, samp_rate=samp_rate, ) self.blocks_message_strobe_0_1 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_0), 1000) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0_0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0)) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.delay_correct_hier_0, 'enable_sync')) self.msg_connect((self.blocks_message_strobe_0_1, 'strobe'), (self.wifius_blocker_0, 'enable_stop')) self.msg_connect((self.wifius_find_scale_factor_0, 'message'), (self.wifius_divide_by_message_0, 'set_divisor')) self.msg_connect((self.wifius_find_scale_factor_0_0, 'message'), (self.wifius_divide_by_message_0_0, 'set_divisor')) self.connect((self.analog_sig_source_x_0, 0), (self.blks2_valve_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_valve_0_0, 0)) self.connect((self.blks2_valve_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.delay_correct_hier_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.delay_correct_hier_0, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.wifius_blocker_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.wifius_blocker_0, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.wifius_divide_by_message_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.wifius_divide_by_message_0_0, 0)) self.connect((self.wifius_blocker_0, 0), (self.wifius_find_scale_factor_0, 0)) self.connect((self.wifius_blocker_0, 1), (self.wifius_find_scale_factor_0_0, 0)) self.connect((self.wifius_divide_by_message_0, 0), (self.delay_correct_hier_0, 0)) self.connect((self.wifius_divide_by_message_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.wifius_divide_by_message_0_0, 0), (self.delay_correct_hier_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.freq_slider_0 = freq_slider_0 = 93.6 self.radio_freq = radio_freq = freq_slider_0 * 1e6 self.offset_freq = offset_freq = -100000 self.filter_taps2 = filter_taps2 = [1] self.filter_taps1 = filter_taps1 = firdes.low_pass( 1, samp_rate, 100000, 1000, firdes.WIN_HAMMING) ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_f( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=48000, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_f( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=48000, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=True, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=6, decimation=25, taps=None, fractional_bw=None, ) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, 200000, 16000, 2000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 5, (filter_taps1), offset_freq, samp_rate) _freq_slider_0_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_slider_0_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_slider_0_sizer, value=self.freq_slider_0, callback=self.set_freq_slider_0, label='freq_slider_0', converter=forms.float_converter(), proportion=0, ) self._freq_slider_0_slider = forms.slider( parent=self.GetWin(), sizer=_freq_slider_0_sizer, value=self.freq_slider_0, callback=self.set_freq_slider_0, minimum=88, maximum=108, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_slider_0_sizer) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "Documents/gnuradio/cap.cpx", True) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1, open=bool(0)) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=200000, audio_decimation=1, ) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_valve_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blks2_valve_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blks2_valve_0, 0))
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature #print "Starting log_receiver init()" self.audiorate = options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 self.audiotaps = gr.firdes.low_pass(1, self.rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf(self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(self.rate)) #sampling rate #on a trunked network where you know you will have good signal, a carrier power squelch works well. real FM receviers use a noise squelch, where #the received audio is high-passed above the cutoff and then fed to a reverse squelch. If the power is then BELOW a threshold, open the squelch. self.squelch = gr.pwr_squelch_cc(options.squelch, #squelch point alpha = 0.1, #wat ramp = 10, #wat gate = True) #gated so that the audio recording doesn't contain blank spaces between transmissions self.audiodemod = blks2.fm_demod_cf(self.rate/self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) #self.audiogain = gr.multiply_const_ff(options.volume) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) #self.prefiltervalve = grc_blks2.valve(gr.sizeof_gr_complex, bool(1)) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #this version allows appending to existing files. # self.connect(self, self.audio_prefilter, self.squelch, self.audiodemod, self.valve, self.audiofilt, self.audiosink) self.connect(self, self.audio_prefilter, self.audiodemod, self.valve, self.audiofilt, self.audiosink) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted.
def __init__(self, talkgroup, options): gr.hier_block2.__init__( self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature #print "Starting log_receiver init()" self.audiorate = options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 self.audiotaps = gr.firdes.low_pass(1, self.rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf( self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(self.rate)) #sampling rate #on a trunked network where you know you will have good signal, a carrier power squelch works well. real FM receviers use a noise squelch, where #the received audio is high-passed above the cutoff and then fed to a reverse squelch. If the power is then BELOW a threshold, open the squelch. self.squelch = gr.pwr_squelch_cc( options.squelch, #squelch point alpha=0.1, #wat ramp=10, #wat gate=True ) #gated so that the audio recording doesn't contain blank spaces between transmissions self.audiodemod = blks2.fm_demod_cf( self.rate / self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) #self.audiogain = gr.multiply_const_ff(options.volume) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ( "".join([ random.choice(string.letters + string.digits) for x in range(8) ]) ) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) #self.prefiltervalve = grc_blks2.valve(gr.sizeof_gr_complex, bool(1)) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a') self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink( self.filename, 1, self.audiorate, 8) #this version allows appending to existing files. # self.connect(self, self.audio_prefilter, self.squelch, self.audiodemod, self.valve, self.audiofilt, self.audiosink) self.connect(self, self.audio_prefilter, self.audiodemod, self.valve, self.audiofilt, self.audiosink) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted.
def __init__(self): gr.top_block.__init__(self, "Calibration Example") Qt.QWidget.__init__(self) self.setWindowTitle("Calibration Example") 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", "calibration_example_gui_manual") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.speed_of_light = speed_of_light = 299792458 self.antenna_spacing = antenna_spacing = 0.1 self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1 self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 0 self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1 self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0 self.samp_rate = samp_rate = 100000000/64 self.gain_rx = gain_rx = 0 self.center_freq = center_freq = speed_of_light/(2*antenna_spacing) self.cal_freq = cal_freq = 1024 self.Shift_1 = Shift_1 = -4 self.Shift_0 = Shift_0 = -4 self.Shift = Shift = -4 ################################################## # Blocks ################################################## self._variable_qtgui_chooser_0_1_1_options = (1, 0, ) self._variable_qtgui_chooser_0_1_1_labels = ("Not Started", "Start Save", ) self._variable_qtgui_chooser_0_1_1_group_box = Qt.QGroupBox("Trigger Data Save") self._variable_qtgui_chooser_0_1_1_box = Qt.QHBoxLayout() 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._variable_qtgui_chooser_0_1_1_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_1_1_group_box.setLayout(self._variable_qtgui_chooser_0_1_1_box) for i, label in enumerate(self._variable_qtgui_chooser_0_1_1_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_1_1_box.addWidget(radio_button) self._variable_qtgui_chooser_0_1_1_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_1_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_1_options.index(i))) self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1) self._variable_qtgui_chooser_0_1_1_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_1_group_box) self._variable_qtgui_chooser_0_0_0_options = (0, 1, ) self._variable_qtgui_chooser_0_0_0_labels = ("Enable", "Disable", ) self._variable_qtgui_chooser_0_0_0_group_box = Qt.QGroupBox("Distant Transmitter Enable") self._variable_qtgui_chooser_0_0_0_box = Qt.QHBoxLayout() 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._variable_qtgui_chooser_0_0_0_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_0_box) for i, label in enumerate(self._variable_qtgui_chooser_0_0_0_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_0_0_box.addWidget(radio_button) self._variable_qtgui_chooser_0_0_0_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_0_options.index(i))) self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0) self._variable_qtgui_chooser_0_0_0_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_0_group_box) self._variable_qtgui_chooser_0_0_options = (0, 1, ) self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", ) self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable") self._variable_qtgui_chooser_0_0_box = Qt.QHBoxLayout() 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._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box) for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_0_box.addWidget(radio_button) self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i))) self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0) self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box) self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Input") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Post Gain Correct") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Post Phase Correct") self.top_layout.addWidget(self.tab) self._Shift_1_range = Range(-4, 4, 0.01, -4, 200) self._Shift_1_win = RangeWidget(self._Shift_1_range, self.set_Shift_1, "Shift", "counter_slider", float) self.top_layout.addWidget(self._Shift_1_win) self._Shift_0_range = Range(-4, 4, 0.01, -4, 200) self._Shift_0_win = RangeWidget(self._Shift_0_range, self.set_Shift_0, "Shift", "counter_slider", float) self.top_layout.addWidget(self._Shift_0_win) self._Shift_range = Range(-4, 4, 0.01, -4, 200) self._Shift_win = RangeWidget(self._Shift_range, self.set_Shift, "Shift", "counter_slider", float) self.top_layout.addWidget(self._Shift_win) self._variable_qtgui_chooser_0_1_0_options = (1, 0, ) self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", ) self._variable_qtgui_chooser_0_1_0_group_box = Qt.QGroupBox("Sync System") self._variable_qtgui_chooser_0_1_0_box = Qt.QHBoxLayout() 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._variable_qtgui_chooser_0_1_0_button_group = variable_chooser_button_group() self._variable_qtgui_chooser_0_1_0_group_box.setLayout(self._variable_qtgui_chooser_0_1_0_box) for i, label in enumerate(self._variable_qtgui_chooser_0_1_0_labels): radio_button = Qt.QRadioButton(label) self._variable_qtgui_chooser_0_1_0_box.addWidget(radio_button) self._variable_qtgui_chooser_0_1_0_button_group.addButton(radio_button, i) self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i))) self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0) self._variable_qtgui_chooser_0_1_0_button_group.buttonClicked[int].connect( lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i])) self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_group_box) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr0=192.168.70.2,addr1=192.168.20.2,addr2=192.168.30.2,addr3=192.168.50.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(4), ), ) self.uhd_usrp_source_0_0.set_clock_source("external", 0) self.uhd_usrp_source_0_0.set_time_source("external", 0) self.uhd_usrp_source_0_0.set_clock_source("external", 1) self.uhd_usrp_source_0_0.set_time_source("external", 1) self.uhd_usrp_source_0_0.set_clock_source("external", 2) self.uhd_usrp_source_0_0.set_time_source("external", 2) self.uhd_usrp_source_0_0.set_clock_source("external", 3) self.uhd_usrp_source_0_0.set_time_source("external", 3) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_source_0_0.set_gain(gain_rx, 0) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1) self.uhd_usrp_source_0_0.set_gain(gain_rx, 1) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2) self.uhd_usrp_source_0_0.set_gain(gain_rx, 2) self.uhd_usrp_source_0_0.set_center_freq(center_freq, 3) self.uhd_usrp_source_0_0.set_gain(gain_rx, 3) self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.80.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0_0.set_gain(30, 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.40.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0) self.uhd_usrp_sink_0_0.set_time_source("mimo", 0) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0_0.set_gain(10, 0) self.save_data_hier_0 = save_data_hier( keep=1, samples=2**22, skips=2**18, vec_size=1, ) self.real_time_scope_hier_0_0_0 = real_time_scope_hier( npoints=3000, samp_rate=samp_rate, ) self.tab_layout_2.addWidget(self.real_time_scope_hier_0_0_0) self.real_time_scope_hier_0 = real_time_scope_hier( npoints=3000, samp_rate=samp_rate, ) self.tab_layout_0.addWidget(self.real_time_scope_hier_0) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_1),numpy.sin(Shift_1)), )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_0),numpy.sin(Shift_0)), )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((complex(numpy.cos(Shift),numpy.sin(Shift)), )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000) self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0_0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0)) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.save_data_hier_0, 'Trigger')) self.connect((self.analog_sig_source_x_0, 0), (self.blks2_valve_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_valve_0_0, 0)) self.connect((self.blks2_valve_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.real_time_scope_hier_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.save_data_hier_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.real_time_scope_hier_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.save_data_hier_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.real_time_scope_hier_0_0_0, 3)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.save_data_hier_0, 3)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 2), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.uhd_usrp_source_0_0, 3), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.real_time_scope_hier_0, 1)) self.connect((self.uhd_usrp_source_0_0, 2), (self.real_time_scope_hier_0, 2)) self.connect((self.uhd_usrp_source_0_0, 3), (self.real_time_scope_hier_0, 3)) self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.save_data_hier_0, 0))
def __init__(self): gr.top_block.__init__(self, "RX logic") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 192000 self.mode = mode = 2 self.bw = bw = 3200 self.aud_rate = aud_rate = 22050 self.visualsq = visualsq = 1 self.st = st = 1 self.sq = sq = -700 self.sb_pos = sb_pos = ((bw*mode==2)-(bw*mode==3)) self.rec = rec = 1 self.laj_0 = laj_0 = 0 self.laj = laj = 0 self.lai_0 = lai_0 = 0 self.lai = lai = 0 self.freq = freq = 98500000 self.device = device = "fcd=0,type=2" self.dev = dev = 19000 self.decimation = decimation = samp_rate/aud_rate self.batswitch = batswitch = 0 self.batido = batido = 2950 self.VEC = VEC = 1280 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="nchan=" + str(1) + " " + device ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(7, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(0, 0) self.rtlsdr_source_0.set_gain(14, 0) self.rtlsdr_source_0.set_if_gain(14, 0) self.rtlsdr_source_0.set_bb_gain(14, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.probe_st = analog.probe_avg_mag_sqrd_f(10, 1) self.low_pass_filter_0_2 = filter.fir_filter_ccf(decimation, firdes.low_pass( 1, samp_rate, bw*(2+(mode==2)+(mode==3)), 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_1_0_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 14000, 1000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_1 = filter.fir_filter_fff(1, firdes.low_pass( 30, samp_rate, 14000, 1000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0_0_0 = filter.interp_fir_filter_fff(1, firdes.low_pass( visualsq, samp_rate/decimation, bw, 10, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decimation, bw, 10, firdes.WIN_HAMMING, 6.76)) self.high_pass_filter_0 = filter.fir_filter_ccf(1, firdes.high_pass( 1, samp_rate/decimation, bw, 10, firdes.WIN_HAMMING, 6.76)) self.fractional_resampler_xx_0_0_0 = filter.fractional_resampler_ff(0, samp_rate/48000.0) self.fractional_resampler_xx_0_0 = filter.fractional_resampler_ff(0, samp_rate/48000.0) self.fractional_resampler_xx_0 = filter.fractional_resampler_ff(0, (samp_rate/decimation)/48000.0) self.fft_vxx_0 = fft.fft_vcc(VEC, True, (window.blackmanharris(1024)), True, 1) self.fft_probe = blocks.probe_signal_vf(VEC) self.blocks_wavfile_sink_0 = blocks.wavfile_sink("/tmp/CAPTURE.WAV", 2, 48000, 16) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, VEC) self.blocks_multiply_xx_0_1_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0_0_0_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(VEC) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((-complex(lai,laj), )) self.blks2_valve_0_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec)) self.blks2_valve_0_0_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(mode!=5)) self.blks2_valve_0_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(0)) self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(mode!=4)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec)) self.blks2_selector_0_1_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=(mode==3), output_index=0, ) self.blks2_selector_0_0_1_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=(mode>3)+(mode>4), output_index=0, ) self.blks2_selector_0_0_1 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=3, num_outputs=1, input_index=(mode>3)+(mode>4), output_index=0, ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=4, num_outputs=1, input_index=mode, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=4, input_index=0, output_index=mode, ) self.band_pass_filter_0_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 250, samp_rate, 18500, 19500, 500, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 120, samp_rate, 24000, 52000, 1000, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "dmix:CARD=Pro,DEV=0", False) self.analog_wfm_rcv_1 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=1, ) self.analog_sig_source_x_0_0_0 = analog.sig_source_c(samp_rate/decimation, analog.GR_COS_WAVE, -bw, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, dev+(bw*mode==2)+(bw*mode==3), 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.25) self.analog_fm_demod_cf_0 = analog.fm_demod_cf( channel_rate=samp_rate, audio_decim=samp_rate/48000, deviation=50000, audio_pass=15000, audio_stop=16000, gain=3.0, tau=50e-6, ) self.analog_fm_deemph_0_0 = analog.fm_deemph(fs=48000, tau=50e-6) self.analog_fm_deemph_0 = analog.fm_deemph(fs=48000, tau=50e-6) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(64, 0.9) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate/decimation, audio_decim=samp_rate/decimation/aud_rate, audio_pass=(samp_rate/decimation/2)-500, audio_stop=(samp_rate/decimation/2)-100, ) self.analog_agc3_xx_0 = analog.agc3_cc(0.0001, 0.0001, 0.9, 0.1) self.analog_agc3_xx_0.set_max_gain(200) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.fft_probe, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_valve_0_0_0, 0), (self.blocks_multiply_xx_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.blocks_add_const_vxx_0, 0), (self.blks2_valve_0_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_1_0, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.analog_fm_deemph_0, 0)) self.connect((self.analog_fm_deemph_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_wfm_rcv_1, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.analog_wfm_rcv_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_wfm_rcv_1, 0), (self.band_pass_filter_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_0_1_0_0_0, 0), (self.analog_fm_deemph_0_0, 0)) self.connect((self.analog_agc3_xx_0, 0), (self.analog_wfm_rcv_1, 0)) self.connect((self.blks2_valve_0_0_1, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blks2_valve_0_0_1, 0)) self.connect((self.blocks_multiply_xx_0_1_0, 0), (self.low_pass_filter_0_1_0_0_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.blocks_multiply_xx_0_1_0, 1)) self.connect((self.band_pass_filter_0_0_0, 0), (self.blocks_multiply_xx_0_1_0, 2)) self.connect((self.analog_fm_deemph_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.analog_fm_deemph_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.fractional_resampler_xx_0_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.fractional_resampler_xx_0_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.analog_fm_demod_cf_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blks2_valve_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_2, 0)) self.connect((self.blocks_complex_to_real_0_0_0_0, 0), (self.blks2_selector_0_0, 3)) self.connect((self.blocks_complex_to_real_0_0_0_0, 0), (self.blks2_selector_0_0, 2)) self.connect((self.blks2_selector_0_1_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_complex_to_real_0_0_0_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.analog_am_demod_cf_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blks2_selector_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.blks2_selector_0, 1), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.low_pass_filter_0_0_0_0, 0)) self.connect((self.blks2_selector_0, 2), (self.high_pass_filter_0, 0)) self.connect((self.blks2_selector_0, 3), (self.low_pass_filter_0_0_0, 0)) self.connect((self.high_pass_filter_0, 0), (self.blks2_selector_0_1_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.blks2_selector_0_1_0, 1)) self.connect((self.analog_fm_demod_cf_0, 0), (self.blks2_selector_0_0_1, 1)) self.connect((self.analog_fm_demod_cf_0, 0), (self.blks2_selector_0_0_1_0, 1)) self.connect((self.fractional_resampler_xx_0_0_0, 0), (self.blks2_selector_0_0_1_0, 2)) self.connect((self.fractional_resampler_xx_0_0, 0), (self.blks2_selector_0_0_1, 2)) self.connect((self.blks2_selector_0_0_1_0, 0), (self.audio_sink_0, 1)) self.connect((self.blks2_selector_0_0_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_valve_0, 0), (self.blocks_wavfile_sink_0, 1)) self.connect((self.blks2_selector_0_0_1_0, 0), (self.blks2_valve_0, 0)) self.connect((self.blks2_selector_0_0_1, 0), (self.blks2_valve_0_1, 0)) self.connect((self.blks2_valve_0_1, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.blks2_selector_0_0_1_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.blks2_selector_0_0_1, 0)) self.connect((self.low_pass_filter_0_2, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_0_0_0_0, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.blks2_selector_0, 0)) self.connect((self.band_pass_filter_0_0_0, 0), (self.probe_st, 0))
def __init__(self): gr.top_block.__init__(self, "Comms Signal Viewer") Qt.QWidget.__init__(self) self.setWindowTitle("Comms Signal Viewer") 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", "SignalViewer") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 self.recordBool = recordBool = True self.fskDemodBool = fskDemodBool = True self.freq = freq = 100e6 self.fmDemodBool = fmDemodBool = True ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(self._samp_rate_line_edit.text().toAscii()))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 4,1,1,2) _recordBool_check_box = Qt.QCheckBox("Don't Record IQ") self._recordBool_choices = {True: True, False: False} self._recordBool_choices_inv = dict((v,k) for k,v in self._recordBool_choices.iteritems()) self._recordBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_recordBool_check_box, "setChecked", Qt.Q_ARG("bool", self._recordBool_choices_inv[i])) self._recordBool_callback(self.recordBool) _recordBool_check_box.stateChanged.connect(lambda i: self.set_recordBool(self._recordBool_choices[bool(i)])) self.top_grid_layout.addWidget(_recordBool_check_box, 6,4,1,1) self.main_tab = Qt.QTabWidget() self.main_tab_widget_0 = Qt.QWidget() self.main_tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_0) self.main_tab_grid_layout_0 = Qt.QGridLayout() self.main_tab_layout_0.addLayout(self.main_tab_grid_layout_0) self.main_tab.addTab(self.main_tab_widget_0, "PSD") self.main_tab_widget_1 = Qt.QWidget() self.main_tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.main_tab_widget_1) self.main_tab_grid_layout_1 = Qt.QGridLayout() self.main_tab_layout_1.addLayout(self.main_tab_grid_layout_1) self.main_tab.addTab(self.main_tab_widget_1, "Waterfall") self.top_grid_layout.addWidget(self.main_tab, 1,1,3,5) self._freq_layout = Qt.QHBoxLayout() self._freq_layout.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(10e6, 6e9, 0.5e6) self._freq_counter.setNumButtons(2) self._freq_counter.setMinimumWidth(200) self._freq_counter.setValue(self.freq) self._freq_layout.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self.top_grid_layout.addLayout(self._freq_layout, 4,3,1,3) self.volumeBlock = blocks.multiply_const_vff((100, )) self.recordIQ = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(recordBool)) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=48, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024*4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc 1e6/4, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_char, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 7,1,1,5) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024*4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc 1e6/4, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.main_tab_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(0, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 100e3, 1e6, firdes.WIN_HAMMING, 6.76)) _fskDemodBool_check_box = Qt.QCheckBox("Don't FSK Demod") self._fskDemodBool_choices = {True: True, False: False} self._fskDemodBool_choices_inv = dict((v,k) for k,v in self._fskDemodBool_choices.iteritems()) self._fskDemodBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_fskDemodBool_check_box, "setChecked", Qt.Q_ARG("bool", self._fskDemodBool_choices_inv[i])) self._fskDemodBool_callback(self.fskDemodBool) _fskDemodBool_check_box.stateChanged.connect(lambda i: self.set_fskDemodBool(self._fskDemodBool_choices[bool(i)])) self.top_grid_layout.addWidget(_fskDemodBool_check_box, 6,3, 1,1) self.fskDemod = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(fskDemodBool)) _fmDemodBool_check_box = Qt.QCheckBox("Don't FM Demod") self._fmDemodBool_choices = {True: True, False: False} self._fmDemodBool_choices_inv = dict((v,k) for k,v in self._fmDemodBool_choices.iteritems()) self._fmDemodBool_callback = lambda i: Qt.QMetaObject.invokeMethod(_fmDemodBool_check_box, "setChecked", Qt.Q_ARG("bool", self._fmDemodBool_choices_inv[i])) self._fmDemodBool_callback(self.fmDemodBool) _fmDemodBool_check_box.stateChanged.connect(lambda i: self.set_fmDemodBool(self._fmDemodBool_choices[bool(i)])) self.top_grid_layout.addWidget(_fmDemodBool_check_box, 6,2,1,1) self.fmDemod = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(fmDemodBool)) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=500e3, audio_decimation=10, ) self.IQData = blocks.file_sink(gr.sizeof_gr_complex*1, "/Users/ryanlagoy/Documents/Repositories/comms/HackRF/GNURadio/IQData.bin", False) self.IQData.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.analog_wfm_rcv_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.fmDemod, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.fskDemod, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.fmDemod, 0)) self.connect((self.osmosdr_source_0, 0), (self.fskDemod, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.recordIQ, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.volumeBlock, 0)) self.connect((self.recordIQ, 0), (self.IQData, 0)) self.connect((self.volumeBlock, 0), (self.audio_sink_0, 0))
def __init__(self, clock=100.0e6, dcg=1, decln=-28.0, devid="addr=192.168.10.2", fftsize=8192, frequency=1.406e9, maxg=50, rfgain=0.0, rxant="", spa=1, srate=10.0e6, subdev="A:0", tpint=2.0): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200 with Filter") ################################################## # Parameters ################################################## self.clock = clock self.dcg = dcg self.decln = decln self.devid = devid self.fftsize = fftsize self.frequency = frequency self.maxg = maxg self.rfgain = rfgain self.rxant = rxant self.spa = spa self.srate = srate self.subdev = subdev self.tpint = tpint ################################################## # Variables ################################################## self.israte = israte = srate self.samp_rate = samp_rate = int(israte) self.prefix = prefix = "tpr_" self.filter_band = filter_band = 500e3 self.variable_static_text_0_0_0_0 = variable_static_text_0_0_0_0 = clock self.variable_static_text_0_0_0 = variable_static_text_0_0_0 = devid self.variable_static_text_0_0 = variable_static_text_0_0 = subdev self.variable_static_text_0 = variable_static_text_0 = israte self.taps = taps = firdes.low_pass(1.0, samp_rate,filter_band, 1000) self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = int(spa) self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.integ = integ = tpint self.idecln = idecln = decln self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = int(dcg) self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_filter = add_filter = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) self._israte_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.israte, callback=self.set_israte, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._israte_chooser, 1, 3, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._add_filter_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_filter, callback=self.set_add_filter, label="Filter On/Off", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_filter_chooser, 3, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=israte, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0_0, callback=self.set_variable_static_text_0_0_0_0, label="N200 Clock", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_0_static_text, 2, 3, 1, 1) self._variable_static_text_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0, callback=self.set_variable_static_text_0_0_0, label="Device", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_static_text, 2, 2, 1, 1) self._variable_static_text_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0, callback=self.set_variable_static_text_0_0, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 2, 1, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 2, 0, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self._idecln_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.idecln, callback=self.set_idecln, label="Declination", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._idecln_text_box, 1, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=maxg, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) _filter_band_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_band_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, label="Filter Bandwidth", converter=forms.float_converter(), proportion=0, ) self._filter_band_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, minimum=100e3, maximum=9e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_filter_band_sizer, 3, 2, 1, 1) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (taps), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=add_filter, output_index=0, ) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .5, 0) self.TPR_0 = TPR( integ=integ, samp_rate=samp_rate, det_rate=det_rate, ) ################################################## # Connections ################################################## self.connect((self.TPR_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.TPR_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blks2_valve_2, 0)) self.connect((self.blks2_selector_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blks2_selector_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))
def __init__(self, subdev="A:0", devid="type=usrp1", frequency=216928000, ant="TX/RX", gain=10, enable_filter=0, rate=3.2e6): grc_wxgui.top_block_gui.__init__(self, title="DAB VHF Baseband Player for UHD (USRP)") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.subdev = subdev self.devid = devid self.frequency = frequency self.ant = ant self.gain = gain self.enable_filter = enable_filter self.rate = rate ################################################## # Variables ################################################## self.transition0 = transition0 = 150000 self.switch2 = switch2 = 1 self.switch1 = switch1 = enable_filter self.switch0 = switch0 = False self.samp_rate = samp_rate = int(rate) self.gain0 = gain0 = gain self.frequency0 = frequency0 = frequency self.dgain = dgain = 1.0/32768 self.cutoff0 = cutoff0 = 810000 ################################################## # Blocks ################################################## _transition0_sizer = wx.BoxSizer(wx.VERTICAL) self._transition0_text_box = forms.text_box( parent=self.GetWin(), sizer=_transition0_sizer, value=self.transition0, callback=self.set_transition0, label="Transition frequency", converter=forms.float_converter(), proportion=0, ) self._transition0_slider = forms.slider( parent=self.GetWin(), sizer=_transition0_sizer, value=self.transition0, callback=self.set_transition0, minimum=100, maximum=1000000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_transition0_sizer, 6, 0, 1, 20) self._switch2_check_box = forms.check_box( parent=self.GetWin(), value=self.switch2, callback=self.set_switch2, label="Spectrum display mute", true=1, false=0, ) self.GridAdd(self._switch2_check_box, 3, 0, 1, 1) self._switch1_check_box = forms.check_box( parent=self.GetWin(), value=self.switch1, callback=self.set_switch1, label="Filter", true=1, false=0, ) self.GridAdd(self._switch1_check_box, 4, 0, 1, 1) self._switch0_check_box = forms.check_box( parent=self.GetWin(), value=self.switch0, callback=self.set_switch0, label="Clean carrier (Modulator Off)", true=1.0, false=0, ) self.GridAdd(self._switch0_check_box, 2, 0, 1, 1) _gain0_sizer = wx.BoxSizer(wx.VERTICAL) self._gain0_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain0_sizer, value=self.gain0, callback=self.set_gain0, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain0_slider = forms.slider( parent=self.GetWin(), sizer=_gain0_sizer, value=self.gain0, callback=self.set_gain0, minimum=0, maximum=20, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain0_sizer, 1, 0, 1, 20) self._frequency0_chooser = forms.drop_down( parent=self.GetWin(), value=self.frequency0, callback=self.set_frequency0, label="Channel frequency", choices=[174928000, 176640000, 178352000, 180064000, 181936000, 183648000, 185360000, 187072000, 188928000, 190640000, 192352000, 194064000, 195936000, 197648000, 199360000, 201072000, 202928000, 204640000, 206352000, 208064000, 209936000, 211648000, 213360000, 215072000, 216928000, 218640000, 220352000, 222064000, 223936000, 225648000, 227360000, 229072000, 230784000, 232496000, 234208000, 235776000, 237488000, 239200000], labels=["5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D", "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A", "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F"], ) self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1) _dgain_sizer = wx.BoxSizer(wx.VERTICAL) self._dgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_dgain_sizer, value=self.dgain, callback=self.set_dgain, label="Digital Gain", converter=forms.float_converter(), proportion=0, ) self._dgain_slider = forms.slider( parent=self.GetWin(), sizer=_dgain_sizer, value=self.dgain, callback=self.set_dgain, minimum=0, maximum=1.0/10000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_dgain_sizer, 7, 0, 1, 20) _cutoff0_sizer = wx.BoxSizer(wx.VERTICAL) self._cutoff0_text_box = forms.text_box( parent=self.GetWin(), sizer=_cutoff0_sizer, value=self.cutoff0, callback=self.set_cutoff0, label="Cutoff Frequency", converter=forms.float_converter(), proportion=0, ) self._cutoff0_slider = forms.slider( parent=self.GetWin(), sizer=_cutoff0_sizer, value=self.cutoff0, callback=self.set_cutoff0, minimum=1, maximum=1500000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=5, y_divs=15, ref_level=60, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=5, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr=devid, stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(frequency0, 0) self.uhd_usrp_sink_0.set_gain(gain0, 0) self.uhd_usrp_sink_0.set_antenna(ant, 0) self.low_pass_filter_0 = gr.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff0, transition0, firdes.WIN_HAMMING, 6.76)) self.gr_multiply_const_vxx_0 = gr.multiply_const_vcc((dgain, )) self.gr_file_source_0 = gr.file_source(gr.sizeof_gr_complex*1, "/dev/stdin", False) self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch0)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(switch2)) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=switch1, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=1, num_outputs=2, input_index=0, output_index=switch1, ) ################################################## # Connections ################################################## self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1)) self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0)) self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0)) self.connect((self.gr_file_source_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0)) self.connect((self.blks2_valve_1_0, 0), (self.gr_multiply_const_vxx_0, 0)) self.connect((self.gr_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "RTL SDR FM RX") Qt.QWidget.__init__(self) self.setWindowTitle("RTL SDR FM RX") 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", "RTL_FM_RX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.88e6 self.rfgain = rfgain = 10 self.freq = freq = 103.8 self.ch_rate = ch_rate = 240e3 self.audio_mute = audio_mute = False self.audio_cut = audio_cut = 12e3 self.afgain = afgain = -10 ################################################## # Blocks ################################################## self._rfgain_range = Range(0, 49, 0.1, 10, 200) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._rfgain_win, 2, 0, 1, 1) self._freq_range = Range(88.0, 108.0, 0.1, 103.8, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Freq (MHz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_win, 1, 0, 1, 3) _audio_mute_check_box = Qt.QCheckBox('Audio Mute') self._audio_mute_choices = {True: True, False: False} self._audio_mute_choices_inv = dict( (v, k) for k, v in self._audio_mute_choices.iteritems()) self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( _audio_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._audio_mute_choices_inv[i])) self._audio_mute_callback(self.audio_mute) _audio_mute_check_box.stateChanged.connect( lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)])) self.top_layout.addWidget(_audio_mute_check_box) self._afgain_range = Range(-20, 3, 0.1, -10, 200) self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float) self.top_grid_layout.addWidget(self._afgain_win, 2, 1, 1, 1) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(ch_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq * 1e6, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "red", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [0.75, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 1, 2) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq * 1e6, 0) self.osmosdr_source_0.set_freq_corr(55, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(0, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.fft_filter_xxx_0 = filter.fft_filter_fff( 1, (firdes.low_pass(pow(10.0, afgain / 10.0), ch_rate, 12e3, 6e3, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 10) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1, open=bool(audio_mute)) self.audio_sink_0 = audio.sink(int(ch_rate / 10), '', True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( ch_rate / (2 * math.pi * 250e3 / 8.0)) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blks2_valve_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blks2_valve_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, subdev="A:0", frequency=216928000, ant="TX/RX", gain=10, enable_filter=0, rate=3.2e6, devid="type=b100"): grc_wxgui.top_block_gui.__init__( self, title="DAB VHF Baseband Player for UHD (USRP)") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.subdev = subdev self.frequency = frequency self.ant = ant self.gain = gain self.enable_filter = enable_filter self.rate = rate self.devid = devid ################################################## # Variables ################################################## self.transition0 = transition0 = 150000 self.switch2 = switch2 = 1 self.switch1 = switch1 = enable_filter self.switch0 = switch0 = False self.samp_rate = samp_rate = int(rate) self.gain0 = gain0 = gain self.frequency0 = frequency0 = frequency self.dgain = dgain = 1.0 / 32768 self.cutoff0 = cutoff0 = 810000 ################################################## # Blocks ################################################## _transition0_sizer = wx.BoxSizer(wx.VERTICAL) self._transition0_text_box = forms.text_box( parent=self.GetWin(), sizer=_transition0_sizer, value=self.transition0, callback=self.set_transition0, label="Transition frequency", converter=forms.float_converter(), proportion=0, ) self._transition0_slider = forms.slider( parent=self.GetWin(), sizer=_transition0_sizer, value=self.transition0, callback=self.set_transition0, minimum=100, maximum=1000000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_transition0_sizer, 6, 0, 1, 20) self._switch2_check_box = forms.check_box( parent=self.GetWin(), value=self.switch2, callback=self.set_switch2, label="Spectrum display mute", true=1, false=0, ) self.GridAdd(self._switch2_check_box, 3, 0, 1, 1) self._switch1_check_box = forms.check_box( parent=self.GetWin(), value=self.switch1, callback=self.set_switch1, label="Filter", true=1, false=0, ) self.GridAdd(self._switch1_check_box, 4, 0, 1, 1) self._switch0_check_box = forms.check_box( parent=self.GetWin(), value=self.switch0, callback=self.set_switch0, label="Clean carrier (Modulator Off)", true=1.0, false=0, ) self.GridAdd(self._switch0_check_box, 2, 0, 1, 1) _gain0_sizer = wx.BoxSizer(wx.VERTICAL) self._gain0_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain0_sizer, value=self.gain0, callback=self.set_gain0, label="Gain", converter=forms.float_converter(), proportion=0, ) self._gain0_slider = forms.slider( parent=self.GetWin(), sizer=_gain0_sizer, value=self.gain0, callback=self.set_gain0, minimum=0, maximum=20, num_steps=40, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain0_sizer, 1, 0, 1, 20) self._frequency0_chooser = forms.drop_down( parent=self.GetWin(), value=self.frequency0, callback=self.set_frequency0, label="Channel frequency", choices=[ 174928000, 176640000, 178352000, 180064000, 181936000, 183648000, 185360000, 187072000, 188928000, 190640000, 192352000, 194064000, 195936000, 197648000, 199360000, 201072000, 202928000, 204640000, 206352000, 208064000, 209936000, 211648000, 213360000, 215072000, 216928000, 218640000, 220352000, 222064000, 223936000, 225648000, 227360000, 229072000, 230784000, 232496000, 234208000, 235776000, 237488000, 239200000 ], labels=[ "5A", "5B", "5C", "5D", "6A", "6B", "6C", "6D", "7A", "7B", "7C", "7D", "8A", "8B", "8C", "8D", "9A", "9B", "9C", "9D", "10A", "10B", "10C", "10D", "11A", "11B", "11C", "11D", "12A", "12B", "12C", "12D", "13A", "13B", "13C", "13D", "13E", "13F" ], ) self.GridAdd(self._frequency0_chooser, 0, 0, 1, 1) _dgain_sizer = wx.BoxSizer(wx.VERTICAL) self._dgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_dgain_sizer, value=self.dgain, callback=self.set_dgain, label="Digital Gain", converter=forms.float_converter(), proportion=0, ) self._dgain_slider = forms.slider( parent=self.GetWin(), sizer=_dgain_sizer, value=self.dgain, callback=self.set_dgain, minimum=0, maximum=1.0 / 10000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_dgain_sizer, 7, 0, 1, 20) _cutoff0_sizer = wx.BoxSizer(wx.VERTICAL) self._cutoff0_text_box = forms.text_box( parent=self.GetWin(), sizer=_cutoff0_sizer, value=self.cutoff0, callback=self.set_cutoff0, label="Cutoff Frequency", converter=forms.float_converter(), proportion=0, ) self._cutoff0_slider = forms.slider( parent=self.GetWin(), sizer=_cutoff0_sizer, value=self.cutoff0, callback=self.set_cutoff0, minimum=1, maximum=1500000, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_cutoff0_sizer, 5, 0, 1, 20) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=5, y_divs=15, ref_level=60, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=5, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr=devid, stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec(subdev, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(frequency0, 0) self.uhd_usrp_sink_0.set_gain(gain0, 0) self.uhd_usrp_sink_0.set_antenna(ant, 0) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, cutoff0, transition0, firdes.WIN_HAMMING, 6.76)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((dgain, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/dev/stdin", False) self.blks2_valve_1_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(switch0)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(switch2)) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=switch1, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=switch1, ) ################################################## # Connections ################################################## self.connect((self.blks2_valve_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.blks2_selector_1, 1)) self.connect((self.blks2_selector_0, 0), (self.blks2_selector_1, 0)) self.connect((self.blks2_selector_0, 1), (self.low_pass_filter_0, 0)) self.connect((self.blks2_selector_1, 0), (self.blks2_valve_1_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_valve_1_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf(self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf(self.rate/self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT,dsd.dsd_MOD_AUTO_SELECT,3,2,True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0 , self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.raw_samp_rate = raw_samp_rate = 2e6 self.decimation = decimation = 8 self.sym_rate = sym_rate = 2400 self.samp_rate = samp_rate = raw_samp_rate/decimation self.half_dev = half_dev = 40e3 self.freq_offset = freq_offset = 500 self.bin_width = bin_width = 10e3 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(raw_samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(450E6, 8E6), 0) self.uhd_usrp_source_0.set_gain(30, 0) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 10e3, 300, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass( 2, raw_samp_rate, 250e3, 50e3, firdes.WIN_HAMMING, 6.76)) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, "samples", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(False)) self.band_pass_filter_0_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, -half_dev-bin_width/2+freq_offset, -half_dev+bin_width/2+freq_offset, 500, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate, +half_dev-bin_width/2+freq_offset, +half_dev+bin_width/2+freq_offset, 500, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_0, 0)) self.connect((self.blks2_valve_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_null_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "TGS FM Transciever") Qt.QWidget.__init__(self) self.setWindowTitle("TGS FM Transciever") 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", "fm_transciever") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.rx_center_freq = rx_center_freq = 100e6 self.doppler_freq = doppler_freq = rx_center_freq self.tx_ptt = tx_ptt = 1 self.tx_gain = tx_gain = 30 self.tx_freq = tx_freq = 100e6 self.samp_rate = samp_rate = 250e3 self.rx_switch = rx_switch = 1 self.rx_mode = rx_mode = 1 self.rx_gain = rx_gain = 30 self.doppler_shift = doppler_shift = int(doppler_freq - rx_center_freq) self.doppler_mode = doppler_mode = 0 self.audio_rate = audio_rate = 48e3 self.audio_interp = audio_interp = 4 ################################################## # Blocks ################################################## self.wrapper = Qt.QTabWidget() self.wrapper_widget_0 = Qt.QWidget() self.wrapper_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.wrapper_widget_0) self.wrapper_grid_layout_0 = Qt.QGridLayout() self.wrapper_layout_0.addLayout(self.wrapper_grid_layout_0) self.wrapper.addTab(self.wrapper_widget_0, 'RX') self.wrapper_widget_1 = Qt.QWidget() self.wrapper_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.wrapper_widget_1) self.wrapper_grid_layout_1 = Qt.QGridLayout() self.wrapper_layout_1.addLayout(self.wrapper_grid_layout_1) self.wrapper.addTab(self.wrapper_widget_1, 'TX') self.top_layout.addWidget(self.wrapper) _tx_ptt_push_button = Qt.QPushButton('PTT') self._tx_ptt_choices = {'Pressed': 0, 'Released': 1} _tx_ptt_push_button.pressed.connect( lambda: self.set_tx_ptt(self._tx_ptt_choices['Pressed'])) _tx_ptt_push_button.released.connect( lambda: self.set_tx_ptt(self._tx_ptt_choices['Released'])) self.wrapper_grid_layout_1.addWidget(_tx_ptt_push_button, 1, 0, 1, 4) self._tx_gain_range = Range(0, 90, 1, 30, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.wrapper_grid_layout_1.addWidget(self._tx_gain_win, 0, 2, 1, 2) self._tx_freq_tool_bar = Qt.QToolBar(self) self._tx_freq_tool_bar.addWidget(Qt.QLabel('TX Freq' + ": ")) self._tx_freq_line_edit = Qt.QLineEdit(str(self.tx_freq)) self._tx_freq_tool_bar.addWidget(self._tx_freq_line_edit) self._tx_freq_line_edit.returnPressed.connect(lambda: self.set_tx_freq( eng_notation.str_to_num( str(self._tx_freq_line_edit.text().toAscii())))) self.wrapper_grid_layout_1.addWidget(self._tx_freq_tool_bar, 0, 0, 1, 2) _rx_switch_check_box = Qt.QCheckBox('RX Switch') self._rx_switch_choices = {True: 0, False: 1} self._rx_switch_choices_inv = dict( (v, k) for k, v in self._rx_switch_choices.iteritems()) self._rx_switch_callback = lambda i: Qt.QMetaObject.invokeMethod( _rx_switch_check_box, "setChecked", Qt.Q_ARG("bool", self._rx_switch_choices_inv[i])) self._rx_switch_callback(self.rx_switch) _rx_switch_check_box.stateChanged.connect( lambda i: self.set_rx_switch(self._rx_switch_choices[bool(i)])) self.wrapper_grid_layout_0.addWidget(_rx_switch_check_box, 1, 0, 1, 2) self._rx_mode_options = ( 0, 1, ) self._rx_mode_labels = ( 'NBFM RX', 'WBFM RX', ) self._rx_mode_tool_bar = Qt.QToolBar(self) self._rx_mode_tool_bar.addWidget(Qt.QLabel('RX Mode' + ": ")) self._rx_mode_combo_box = Qt.QComboBox() self._rx_mode_tool_bar.addWidget(self._rx_mode_combo_box) for label in self._rx_mode_labels: self._rx_mode_combo_box.addItem(label) self._rx_mode_callback = lambda i: Qt.QMetaObject.invokeMethod( self._rx_mode_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rx_mode_options.index(i))) self._rx_mode_callback(self.rx_mode) self._rx_mode_combo_box.currentIndexChanged.connect( lambda i: self.set_rx_mode(self._rx_mode_options[i])) self.wrapper_grid_layout_0.addWidget(self._rx_mode_tool_bar, 1, 2, 1, 2) self._rx_gain_range = Range(0, 90, 1, 30, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX gain', "counter_slider", float) self.wrapper_grid_layout_0.addWidget(self._rx_gain_win, 0, 2, 1, 2) self._rx_center_freq_tool_bar = Qt.QToolBar(self) self._rx_center_freq_tool_bar.addWidget(Qt.QLabel('RX Freq' + ": ")) self._rx_center_freq_line_edit = Qt.QLineEdit(str(self.rx_center_freq)) self._rx_center_freq_tool_bar.addWidget(self._rx_center_freq_line_edit) self._rx_center_freq_line_edit.returnPressed.connect( lambda: self.set_rx_center_freq( eng_notation.str_to_num( str(self._rx_center_freq_line_edit.text().toAscii())))) self.wrapper_grid_layout_0.addWidget(self._rx_center_freq_tool_bar, 0, 0, 1, 2) self._doppler_shift_tool_bar = Qt.QToolBar(self) if None: self._doppler_shift_formatter = None else: self._doppler_shift_formatter = lambda x: x self._doppler_shift_tool_bar.addWidget( Qt.QLabel('Doppler Shift' + ": ")) self._doppler_shift_label = Qt.QLabel( str(self._doppler_shift_formatter(self.doppler_shift))) self._doppler_shift_tool_bar.addWidget(self._doppler_shift_label) self.top_layout.addWidget(self._doppler_shift_tool_bar) _doppler_mode_check_box = Qt.QCheckBox('Doppler correction') self._doppler_mode_choices = {True: 1, False: 0} self._doppler_mode_choices_inv = dict( (v, k) for k, v in self._doppler_mode_choices.iteritems()) self._doppler_mode_callback = lambda i: Qt.QMetaObject.invokeMethod( _doppler_mode_check_box, "setChecked", Qt.Q_ARG("bool", self._doppler_mode_choices_inv[i])) self._doppler_mode_callback(self.doppler_mode) _doppler_mode_check_box.stateChanged.connect( lambda i: self.set_doppler_mode(self._doppler_mode_choices[bool(i)] )) self.top_layout.addWidget(_doppler_mode_check_box) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(rx_center_freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(audio_interp * audio_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(audio_rate * audio_interp), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX Waterfall", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget) self.wrapper_grid_layout_0.addWidget( self._qtgui_waterfall_sink_x_0_0_win, 2, 2, 1, 2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Waterfall", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.wrapper_grid_layout_1.addWidget( self._qtgui_waterfall_sink_x_0_win, 2, 2, 1, 2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX FFT", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(True) self.qtgui_freq_sink_x_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.wrapper_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_0_win, 2, 0, 1, 2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX FFT", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.wrapper_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 2) self.gpredict_doppler_0_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(rx_switch)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1, open=bool(tx_ptt)) self.blks2_selector_1_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=doppler_mode, output_index=0, ) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=2, num_outputs=1, input_index=rx_mode, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=rx_mode, ) self.audio_source_0 = audio.source(int(audio_rate), '', True) self.audio_sink_0 = audio.sink(int(audio_rate), '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=audio_interp * audio_rate, audio_decimation=audio_interp, ) self.analog_sig_source_x_1 = analog.sig_source_c( int(audio_rate * audio_interp), analog.GR_COS_WAVE, doppler_shift, 1, 0) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=int(audio_rate), quad_rate=int(audio_rate * audio_interp), tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_nbfm_rx_0 = analog.nbfm_rx( audio_rate=int(audio_rate), quad_rate=int(audio_rate * audio_interp), tau=75e-6, max_dev=5e3, ) ################################################## # Connections ################################################## self.connect((self.analog_nbfm_rx_0, 0), (self.blks2_selector_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_wfm_rcv_0, 0), (self.blks2_selector_1, 1)) self.connect((self.audio_source_0, 0), (self.blks2_valve_0, 0)) self.connect((self.blks2_selector_0, 0), (self.analog_nbfm_rx_0, 0)) self.connect((self.blks2_selector_0, 1), (self.analog_wfm_rcv_0, 0)) self.connect((self.blks2_selector_1, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_selector_1_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_valve_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0)) self.connect((self.blks2_valve_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blks2_selector_1_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blks2_selector_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "bladeRF_transceiver") ################################################## # Variables ################################################## self.symbole_rate = symbole_rate = 10e3 self.samp_rate = samp_rate = 1e6 self.rat_interop = rat_interop = 8 self.rat_decim = rat_decim = 5 self.firdes_transition_width = firdes_transition_width = 15000 self.firdes_decim = firdes_decim = 4 self.firdes_cuttoff = firdes_cuttoff = 21e3 self.tx_valve_value = tx_valve_value = False self.tx_rf_gain = tx_rf_gain = 10 self.tx_bb_gain = tx_bb_gain = -20 self.samp_per_sym_source = samp_per_sym_source = ((samp_rate/2/firdes_decim)*rat_interop/rat_decim) / symbole_rate self.samp_per_sym = samp_per_sym = int(samp_rate / symbole_rate) self.rx_valve_value = rx_valve_value = False self.rx_rf_gain = rx_rf_gain = 3 self.rx_bb_gain = rx_bb_gain = 20 self.preamble = preamble = '0101010101010101' self.msg_source_msgq_in = msg_source_msgq_in = gr.msg_queue(2) self.msg_sink_msgq_out = msg_sink_msgq_out = gr.msg_queue(2) self.frequency_tx = frequency_tx = 450e6 self.frequency_shift = frequency_shift = 520000 self.frequency_rx = frequency_rx = 450.0e6 self.firdes_filter = firdes_filter = firdes.low_pass(1,samp_rate/2, firdes_cuttoff, firdes_transition_width) self.bit_per_sym = bit_per_sym = 1 self.bandwith = bandwith = 6e6 self.access_code = access_code = '11010011100100011101001110010001' ################################################## # Blocks ################################################## self.xlating_fir_filter_1 = filter.freq_xlating_fir_filter_ccc(2, (1, ), frequency_shift, samp_rate) self.xlating_fir_filter_0 = filter.freq_xlating_fir_filter_ccc(firdes_decim, (firdes_filter), 0, samp_rate/2) self.tx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(tx_valve_value)) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate/2,True) self.rx_valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rx_valve_value)) self.rational_resampler = filter.rational_resampler_ccc( interpolation=rat_interop, decimation=rat_decim, taps=None, fractional_bw=None, ) self.quadrature_demod = analog.quadrature_demod_cf(2) self.osmosdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source.set_sample_rate(samp_rate) self.osmosdr_source.set_center_freq(frequency_rx-frequency_shift, 0) self.osmosdr_source.set_freq_corr(0, 0) self.osmosdr_source.set_dc_offset_mode(0, 0) self.osmosdr_source.set_iq_balance_mode(2, 0) self.osmosdr_source.set_gain_mode(False, 0) self.osmosdr_source.set_gain(rx_rf_gain, 0) self.osmosdr_source.set_if_gain(0, 0) self.osmosdr_source.set_bb_gain(rx_bb_gain, 0) self.osmosdr_source.set_antenna("", 0) self.osmosdr_source.set_bandwidth(bandwith, 0) self.osmosdr_sink = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_sink.set_sample_rate(samp_rate) self.osmosdr_sink.set_center_freq(frequency_tx, 0) self.osmosdr_sink.set_freq_corr(0, 0) self.osmosdr_sink.set_gain(tx_rf_gain, 0) self.osmosdr_sink.set_if_gain(0, 0) self.osmosdr_sink.set_bb_gain(tx_bb_gain, 0) self.osmosdr_sink.set_antenna("", 0) self.osmosdr_sink.set_bandwidth(bandwith, 0) self.gmsk_mod = digital.gmsk_mod( samples_per_symbol=int(samp_per_sym), bt=0.5, verbose=False, log=False, ) self.correlate_access_code = digital.correlate_access_code_bb(access_code, 4) self.clock_recovery = digital.clock_recovery_mm_ff(samp_per_sym_source*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.cc1111_packet_encoder = cc1111.cc1111_packet_mod_base(cc1111.cc1111_packet_encoder( samples_per_symbol=samp_per_sym, bits_per_symbol=bit_per_sym, preamble=preamble, access_code=access_code, pad_for_usrp=True, do_whitening=True, add_crc=True ), source_queue=msg_source_msgq_in ) self.cc1111_packet_decoder = cc1111.cc1111_packet_decoder(msg_sink_msgq_out,True, True, False, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.binary_slicer = digital.binary_slicer_fb() ################################################## # Connections ################################################## self.connect((self.binary_slicer, 0), (self.correlate_access_code, 0)) self.connect((self.cc1111_packet_decoder, 0), (self.blocks_null_sink_0, 0)) self.connect((self.cc1111_packet_encoder, 0), (self.gmsk_mod, 0)) self.connect((self.clock_recovery, 0), (self.binary_slicer, 0)) self.connect((self.correlate_access_code, 0), (self.cc1111_packet_decoder, 0)) self.connect((self.gmsk_mod, 0), (self.tx_valve, 0)) self.connect((self.osmosdr_source, 0), (self.rx_valve, 0)) self.connect((self.quadrature_demod, 0), (self.clock_recovery, 0)) self.connect((self.rational_resampler, 0), (self.quadrature_demod, 0)) self.connect((self.rx_valve, 0), (self.xlating_fir_filter_1, 0)) self.connect((self.throttle, 0), (self.xlating_fir_filter_0, 0)) self.connect((self.tx_valve, 0), (self.osmosdr_sink, 0)) self.connect((self.xlating_fir_filter_0, 0), (self.rational_resampler, 0)) self.connect((self.xlating_fir_filter_1, 0), (self.throttle, 0))
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) self.frame = frame self.panel = panel parser = OptionParser(option_class=eng_option) parser.add_option("-a", "--args", type="string", default="", help="UHD device address args , [default=%default]") parser.add_option("", "--spec", type="string", default=None, help="Subdevice of UHD device where appropriate") parser.add_option("-A", "--antenna", type="string", default=None, help="select Rx Antenna where appropriate") parser.add_option("-s", "--samp-rate", type="eng_float", default=1e6, help="set sample rate (bandwidth) [default=%default]") parser.add_option("-f", "--freq", type="eng_float", default=None, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") parser.add_option("-W", "--waterfall", action="store_true", default=False, help="Enable waterfall display") parser.add_option("-S", "--oscilloscope", action="store_true", default=False, help="Enable oscilloscope display") parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, help="Set fftsink averaging factor, default=[%default]") parser.add_option ("", "--averaging", action="store_true", default=False, help="Enable fftsink averaging, default=[%default]") parser.add_option("", "--ref-scale", type="eng_float", default=1.0, help="Set dBFS=0dB input value, default=[%default]") parser.add_option("", "--fft-size", type="int", default=1024, help="Set number of FFT bins [default=%default]") parser.add_option("", "--fft-rate", type="int", default=30, help="Set FFT update rate, [default=%default]") parser.add_option("", "--wire-format", type="string", default="sc16", help="Set wire format from USRP [default=%default]") parser.add_option("", "--stream-args", type="string", default="", help="Set additional stream args [default=%default]") parser.add_option("", "--show-async-msg", action="store_true", default=False, help="Show asynchronous message notifications from UHD [default=%default]") parser.add_option("-b", "--bandwidth", type="eng_float", default=1e6, help="set bandpass filter setting on the RF frontend") parser.add_option("-n", "--nsamples", type="eng_float", default=1024, help="set number of samples which will be saved") parser.add_option("-N", "--samp-avg", type="eng_float", default=10, help="set number of FFT samples which are averaged") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.options = options self.show_debug_info = True #Create USRP object self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args(cpu_format='fc32', otw_format=options.wire_format, args=options.stream_args)) #Create USRP object to transmit data to B200 (LO signal) self.u_lo = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.u_lo.set_samp_rate(320000) self.u_lo.set_center_freq(25000000, 0) self.u_lo.set_gain(0, 0) # Create signal source self.sig_lo= analog.sig_source_c(320000, analog.GR_SIN_WAVE, 25000000, 0.316, 0) #(sample_rate, type, frequency, amplitude, offset) #Valve controls the streaming of LO self.valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=True) self.fft_size=options.fft_size # Set the subdevice spec if(options.spec): self.u.set_subdev_spec(options.spec, 0) # Set the antenna if(options.antenna): self.u.set_antenna(options.antenna, 0) # Set sample rate self.u.set_samp_rate(options.samp_rate) input_rate = self.u.get_samp_rate() # What kind of display will be shown if options.waterfall: self.scope = \ waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate) self.frame.SetMinSize((800, 420)) elif options.oscilloscope: self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) self.frame.SetMinSize((800, 600)) else: self.scope = fftsink2_.fft_sink_c (panel, fft_size=options.fft_size, sample_rate=input_rate, ref_scale=options.ref_scale, ref_level=20.0, y_divs = 12, average=options.averaging, avg_alpha=options.avg_alpha, fft_rate=options.fft_rate) def fftsink_callback(x, y): self.set_freq(x) self.scope.set_callback(fftsink_callback) self.frame.SetMinSize((800, 420)) self.connect(self.u, self.scope) self.connect(self.sig_lo,self.valve, self.u_lo) self._build_gui(vbox) self._setup_events() # set initial values # Get gain if options.gain is None: # if no gain was specified, use the mid-point in dB g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2 #Get frequency if options.freq is None: # if no freq was specified, use the mid-point r = self.u.get_freq_range()#possible frequency range options.freq = float(r.start()+r.stop())/2#middle of the tunable frequency #Following lines must be after defining myform because set_freq, set_nsamples and set_gain need it # Set number of samples to store self.set_nsamples(options.nsamples) # Set bandwidth (passband filter on the RF frontend) self.set_bw(options.bandwidth) # Set gain self.set_gain(options.gain) # Set default LO frequency self.set_lo_freq(25000000)# LO frequency will be 25MHz, by default if self.show_debug_info: self.myform['samprate'].set_value(self.u.get_samp_rate()) self.myform['rffreq'].set_value(0) self.myform['dspfreq'].set_value(0) if not(self.set_freq(options.freq)): self._set_status_msg("Failed to set initial frequency") else: self.set_filename("Data_nsam_"+str(self.nsamp)+"_samprate_"+str(input_rate)+ "_bw_"+str(self.bandwidth)+"_cfreq_"+str(self.u.get_center_freq())+"_.txt") # Direct asynchronous notifications to callback function if self.options.show_async_msg: self.async_msgq = gr.msg_queue(0) self.async_src = uhd.amsg_source("", self.async_msgq) self.async_rcv = gru.msgq_runner(self.async_msgq, self.async_callback)
def __init__(self, talkgroup, options): gr.hier_block2.__init__( self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 10 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE * samp_per_sym self.audio_mul = audio_mul = 1 self.pre_channel_rate = pre_channel_rate = int(samp_rate / decim) self.squelch = squelch = -55 self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Blocks ################################################## print "Setting up Blocks" self.audiotaps = gr.firdes.low_pass(1, samp_rate, 8000, 2000, gr.firdes.WIN_HANN) self.prefilter_decim = int(self.rate / self.audiorate) #the audio prefilter is a channel selection filter. self.audio_prefilter = gr.freq_xlating_fir_filter_ccf( self.prefilter_decim, #decimation self.audiotaps, #taps 0, #freq offset int(samp_rate)) #sampling rate self.audiodemod = blks2.fm_demod_cf( self.rate / self.prefilter_decim, #rate 1, #audio decimation 4000, #deviation 3000, #audio passband 4000, #audio stopband options.volume, #gain 75e-6) #deemphasis constant #the filtering removes FSK data woobling from the subaudible channel self.audiofilttaps = gr.firdes.high_pass(1, self.audiorate, 300, 50, gr.firdes.WIN_HANN) self.audiofilt = gr.fir_filter_fff(1, self.audiofilttaps) self.gr_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 1.6) #(channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth / 2, 2000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = filter.fir_filter_fff( 1, ((1.0 / samp_per_sym, ) * samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (10.**(audio_mul / 10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ( "".join([ random.choice(string.letters + string.digits) for x in range(8) ]) ) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) self.dsd_block_ff_0 = dsd.block_ff(dsd.dsd_FRAME_AUTO_DETECT, dsd.dsd_MOD_AUTO_SELECT, 3, 2, True) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a') self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink( self.filename, 1, self.audiorate, 8 ) #blocks.wavfile_sink(self.filename, 1, self.audiorate, 8) this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. print "Connecting blocks" ################################################## # Connections ################################################## self.connect(self.blks2_rational_resampler_xxx_0, self.blocks_multiply_const_vxx_0) self.connect(self.gr_fir_filter_xxx_0, self.valve, self.dsd_block_ff_0) self.connect(self.dsd_block_ff_0, self.blks2_rational_resampler_xxx_0) ## Start self.connect(self, self.gr_freq_xlating_fir_filter_xxx_0, self.blks2_rational_resampler_xxx_1, self.gr_quadrature_demod_cf_0, self.gr_fir_filter_xxx_0) ## End # self.connect(self.blocks_multiply_const_vxx_0, self.audio_sink_0) # Plays the audio self.connect(self.blocks_multiply_const_vxx_0, self.audiosink) # Records the audio
def __init__(self, freq=394e6, gain=0, sample_rate=2400000, args="", channel_bw=12500, listen_port=60100, ppm=0, output="channel%d.bits", output_offset=None, auto_tune=-1): gr.top_block.__init__(self, "TETRAPOL multichannel reciever") ################################################## # Parameters and variables ################################################## self.freq = freq self.gain = gain self.sample_rate = sample_rate self.args = args self.channel_bw = channel_bw self.listen_port = listen_port self.ppm = ppm self.output = output self.auto_tune = auto_tune # TODO: parametrize self.debug = True self.channels = channels = int(sample_rate/channel_bw) channel_symb_rate = 8000 samples_per_symbol = 2 self.channel_samp_rate = channel_samp_rate = \ channel_symb_rate * samples_per_symbol afc_period = 6 self.afc_gain = 1 self.afc_ppm_threshold = 100 if output_offset is None: self.output_offset = 0 else: self.output_offset = output_offset - ((channels - 1) // 2) ################################################## # Blocks - RPC server ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", listen_port), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() ################################################## # Blocks - RX, demod, sink ################################################## self.src = osmosdr.source( args="numchan=" + str(1) + " " + "" + self.args ) self.src.set_sample_rate(sample_rate) self.src.set_center_freq(freq, 0) self.src.set_freq_corr(ppm, 0) # TODO: manual gain control self.src.set_gain_mode(True, 0) #self.src.set_gain(gain, 0) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, sample_rate) bw = (9200 + self.afc_ppm_threshold)/2 self.channelizer = pfb.channelizer_ccf( channels, firdes.low_pass(1, sample_rate, bw, bw*0.15, firdes.WIN_HANN), float(channel_samp_rate)/(sample_rate/channels), 100) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) self.valves = [] self.gmsk_demods = [] self.file_sinks = [] even_no_of_chs = not (channels % 2) center_ch = channels // 2 for ch_in in range(0, channels): ch_out = (ch_in + center_ch + 1) % channels if ch_out == center_ch and even_no_of_chs: null_sink = blocks.null_sink(gr.sizeof_gr_complex) self.connect( (self.channelizer, ch_out), (null_sink, 0)) continue valve = grc_blks2.valve(item_size=gr.sizeof_gr_complex, open=True) gmsk_demod = digital.gmsk_demod( samples_per_symbol=samples_per_symbol, gain_mu=0.050, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) o = output % (ch_in + self.output_offset) file_sink = blocks.file_sink(gr.sizeof_char, o, False) file_sink.set_unbuffered(True) self.connect( (self.channelizer, ch_out), (valve, 0), (gmsk_demod, 0), (file_sink, 0)) self.valves.append(valve) self.gmsk_demods.append(gmsk_demod) self.file_sinks.append(file_sink) ################################################## # Blocks - automatic fine tune ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=channels - even_no_of_chs, num_outputs=1, input_index=0, output_index=0, ) if auto_tune != -1: self.afc_selector.set_input_index(auto_tune) self.afc_demod = analog.quadrature_demod_cf(channel_samp_rate/(2*math.pi)) afc_samp = channel_samp_rate * afc_period / 2 self.afc_avg = blocks.moving_average_ff(afc_samp, 1./afc_samp*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(afc_period) if self.auto_tune == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_threshold: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "freq err: % .0f\tfreq: %f" % (err, freq) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch_in in range(0, channels - even_no_of_chs): ch_out = (ch_in + center_ch + 1) % channels self.connect((self.channelizer, ch_out), (self.afc_selector, ch_in)) self.connect((self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) ################################################## # Blocks - signal strenght indication ################################################## self.pwr_probes = [] for ch in range(self.channels - even_no_of_chs): ch = (ch + center_ch + 1) % channels pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./channel_samp_rate) self.connect((self.channelizer, ch), (pwr_probe, 0)) self.pwr_probes.append(pwr_probe)
def __init__(self, talkgroup, options): gr.hier_block2.__init__(self, "fsk_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, gr.sizeof_char)) # Output signature #print "Starting log_receiver init()" self.samp_rate = samp_rate = int(options.rate) self.samp_per_sym = samp_per_sym = 5+1 self.decim = decim = 20 self.xlate_bandwidth = xlate_bandwidth = 24260.0 self.xlate_offset = xlate_offset = 0 self.channel_rate = channel_rate = op25.SYMBOL_RATE*samp_per_sym self.audio_mul = audio_mul = 2 self.pre_channel_rate = pre_channel_rate = int(samp_rate/decim) self.auto_tune_offset = auto_tune_offset = 0 self.audiorate = 44100 #options.audiorate self.rate = options.rate self.talkgroup = talkgroup self.directory = options.directory if options.squelch is None: options.squelch = 28 if options.volume is None: options.volume = 3.0 ################################################## # Message Queues ################################################## op25_fsk4_0_msgq_out = baz_message_callback_0_msgq_in = gr.msg_queue(2) op25_decoder_simple_0_msgq_out = op25_traffic_pane_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.op25_fsk4_0 = op25.op25_fsk4(channel_rate=channel_rate, auto_tune_msgq=op25_fsk4_0_msgq_out,) self.op25_decoder_simple_0 = op25.op25_decoder_simple(key="",traffic_msgq=op25_decoder_simple_0_msgq_out,) self.gr_quadrature_demod_cf_0 = gr.quadrature_demod_cf((channel_rate/(2.0 * math.pi * op25.SYMBOL_DEVIATION))) self.gr_freq_xlating_fir_filter_xxx_0 = gr.freq_xlating_fir_filter_ccc(decim, (firdes.low_pass(1, samp_rate, xlate_bandwidth/2, 4000)), 0, samp_rate) self.gr_fir_filter_xxx_0 = gr.fir_filter_fff(1, ((1.0/samp_per_sym,)*samp_per_sym)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10.**(audio_mul/10.), )) self.blks2_rational_resampler_xxx_1 = blks2.rational_resampler_ccc( interpolation=channel_rate, decimation=pre_channel_rate, taps=None, fractional_bw=None, ) self.blks2_rational_resampler_xxx_0 = blks2.rational_resampler_fff( interpolation=self.audiorate, decimation=8000, taps=None, fractional_bw=None, ) self.baz_message_callback_0 = message_callback.message_callback(msgq=baz_message_callback_0_msgq_in, callback=auto_tune_offset , msg_part="arg1", custom_parts="", dummy=False) #here we generate a random filename in the form /tmp/[random].wav, and then use it for the wavstamp block. this avoids collisions later on. remember to clean up these files when deallocating. self.tmpfilename = "/tmp/%s.wav" % ("".join([random.choice(string.letters+string.digits) for x in range(8)])) #if this looks glaringly different, it's because i totally cribbed it from a blog. self.valve = grc_blks2.valve(gr.sizeof_float, bool(1)) #open the logfile for appending self.timestampfilename = "%s/%i.txt" % (self.directory, self.talkgroup) self.timestampfile = open(self.timestampfilename, 'a'); self.filename = "%s/%i.wav" % (self.directory, self.talkgroup) self.audiosink = smartnet.wavsink(self.filename, 1, self.audiorate, 8) #this version allows appending to existing files. self.audio_sink_0 = audio.sink(44100, "", True) self.timestamp = 0.0 #print "Finishing logging receiver init()." self.mute() #start off muted. ################################################## # Connections ################################################## self.connect((self.gr_freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.gr_quadrature_demod_cf_0, 0)) self.connect((self.gr_quadrature_demod_cf_0, 0), (self.gr_fir_filter_xxx_0, 0)) self.connect((self.blks2_rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.gr_fir_filter_xxx_0, 0), (self.op25_fsk4_0, 0)) self.connect((self.op25_fsk4_0, 0), (self.op25_decoder_simple_0, 0)) self.connect((self.op25_decoder_simple_0, 0), (self.blks2_rational_resampler_xxx_0, 0)) ## Start self.connect(self, (self.gr_freq_xlating_fir_filter_xxx_0, 0)) ## End self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0,0))
def __init__(self): gr.top_block.__init__(self, "Merapi Vco Demo") Qt.QWidget.__init__(self) self.setWindowTitle("Merapi Vco Demo") 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", "merapi_vco_demo") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2.4e6 self.rfgain = rfgain = 30 self.ch_rate = ch_rate = 48e3 self.cfreq = cfreq = 165807500 self.bb_rate = bb_rate = 192e3 self.audio_mute = audio_mute = False self.afgain = afgain = -20 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Input Spectrum') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Baseband') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Demodulated Audio') self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, 'Sensor - Voltage') self.tab_widget_4 = Qt.QWidget() self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_4) self.tab_grid_layout_4 = Qt.QGridLayout() self.tab_layout_4.addLayout(self.tab_grid_layout_4) self.tab.addTab(self.tab_widget_4, 'Sensor - Freq') self.tab_widget_5 = Qt.QWidget() self.tab_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_5) self.tab_grid_layout_5 = Qt.QGridLayout() self.tab_layout_5.addLayout(self.tab_grid_layout_5) self.tab.addTab(self.tab_widget_5, 'Tab 5') self.tab_widget_6 = Qt.QWidget() self.tab_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_6) self.tab_grid_layout_6 = Qt.QGridLayout() self.tab_layout_6.addLayout(self.tab_grid_layout_6) self.tab.addTab(self.tab_widget_6, 'Tab 6') self.tab_widget_7 = Qt.QWidget() self.tab_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_7) self.tab_grid_layout_7 = Qt.QGridLayout() self.tab_layout_7.addLayout(self.tab_grid_layout_7) self.tab.addTab(self.tab_widget_7, 'Tab 7') self.tab_widget_8 = Qt.QWidget() self.tab_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_8) self.tab_grid_layout_8 = Qt.QGridLayout() self.tab_layout_8.addLayout(self.tab_grid_layout_8) self.tab.addTab(self.tab_widget_8, 'Tab 8') self.tab_widget_9 = Qt.QWidget() self.tab_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_9) self.tab_grid_layout_9 = Qt.QGridLayout() self.tab_layout_9.addLayout(self.tab_grid_layout_9) self.tab.addTab(self.tab_widget_9, 'Tab 9') self.top_layout.addWidget(self.tab) self._rfgain_range = Range(0, 50, 1, 30, 200) self._rfgain_win = RangeWidget(self._rfgain_range, self.set_rfgain, 'RF Gain (dB)', "counter_slider", float) self.tab_grid_layout_0.addWidget(self._rfgain_win, 1, 1, 1, 1) self._cfreq_tool_bar = Qt.QToolBar(self) self._cfreq_tool_bar.addWidget(Qt.QLabel('Freq. (Hz)' + ": ")) self._cfreq_line_edit = Qt.QLineEdit(str(self.cfreq)) self._cfreq_tool_bar.addWidget(self._cfreq_line_edit) self._cfreq_line_edit.returnPressed.connect(lambda: self.set_cfreq( int(str(self._cfreq_line_edit.text().toAscii())))) self.tab_grid_layout_0.addWidget(self._cfreq_tool_bar, 1, 0, 1, 1) _audio_mute_check_box = Qt.QCheckBox('Audio Mute') self._audio_mute_choices = {True: True, False: False} self._audio_mute_choices_inv = dict( (v, k) for k, v in self._audio_mute_choices.iteritems()) self._audio_mute_callback = lambda i: Qt.QMetaObject.invokeMethod( _audio_mute_check_box, "setChecked", Qt.Q_ARG("bool", self._audio_mute_choices_inv[i])) self._audio_mute_callback(self.audio_mute) _audio_mute_check_box.stateChanged.connect( lambda i: self.set_audio_mute(self._audio_mute_choices[bool(i)])) self.tab_grid_layout_2.addWidget(_audio_mute_check_box, 2, 0, 1, 1) self._afgain_range = Range(-30, -1, 1, -20, 200) self._afgain_win = RangeWidget(self._afgain_range, self.set_afgain, 'AF Gain (dB)', "counter_slider", float) self.tab_grid_layout_2.addWidget(self._afgain_win, 2, 1, 1, 1) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=5, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=10, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(bb_rate), decimation=int(samp_rate), taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 5e3, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.01) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [6, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-50, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_4.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 8192 * 8, #size ch_rate / 10, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-8, 8) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not False: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_2_win, 1, 0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2048, #size ch_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-15, 15) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_2 = qtgui.freq_sink_f( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 10e3, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_2.set_update_time(0.10) self.qtgui_freq_sink_x_2.set_y_axis(-50, 0) self.qtgui_freq_sink_x_2.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_2.enable_autoscale(False) self.qtgui_freq_sink_x_2.enable_grid(True) self.qtgui_freq_sink_x_2.set_fft_average(0.1) self.qtgui_freq_sink_x_2.enable_axis_labels(True) self.qtgui_freq_sink_x_2.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_2.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_2.set_plot_pos_half(not False) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_2.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_2.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_2.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_2_win = sip.wrapinstance( self.qtgui_freq_sink_x_2.pyqwidget(), Qt.QWidget) self.tab_grid_layout_2.addWidget(self._qtgui_freq_sink_x_2_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc bb_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, -20) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) 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 xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 1, 1) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(cfreq + samp_rate / 4, 0) self.osmosdr_source_0.set_freq_corr(55, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(rfgain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.fft_filter_xxx_4 = filter.fft_filter_fff( 1, (firdes.low_pass(1, ch_rate, 5000, 1000, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_4.declare_sample_delay(0) self.fft_filter_xxx_2 = filter.fft_filter_fff(1, (firdes.band_pass( 1, ch_rate, 600, 2000, 600, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_2.declare_sample_delay(0) self.fft_filter_xxx_1_0 = filter.fft_filter_fff( 10, (firdes.low_pass(1, 48000, 40, 40, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_1_0.declare_sample_delay(0) self.fft_filter_xxx_1 = filter.fft_filter_ccc(int( bb_rate / ch_rate), (firdes.low_pass( 1, bb_rate, ch_rate / 2, ch_rate / 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_1.declare_sample_delay(0) self.fft_filter_xxx_0_0 = filter.fft_filter_ccc( 1, (firdes.low_pass(1, 48000, 700, 200, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0_0.declare_sample_delay(0) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (firdes.low_pass( 1, samp_rate, bb_rate / 2, bb_rate / 10, firdes.WIN_BLACKMAN)), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_rotator_cc_0_0 = blocks.rotator_cc( (-1360 / 48000.0) * 2 * math.pi) self.blocks_rotator_cc_0 = blocks.rotator_cc(math.pi / 2) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (pow(10, afgain / 10), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float * 1, open=bool(audio_mute)) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf( ch_rate / (2 * math.pi * 1000 / 8.0)) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( ch_rate / (2 * math.pi * 12500 / 8.0)) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fft_filter_xxx_2, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.fft_filter_xxx_1_0, 0)) self.connect((self.blks2_valve_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_rotator_cc_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_rotator_cc_0_0, 0), (self.fft_filter_xxx_0_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.fft_filter_xxx_0_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.fft_filter_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.fft_filter_xxx_1_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blks2_valve_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.fft_filter_xxx_4, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fft_filter_xxx_2, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.fft_filter_xxx_4, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.fft_filter_xxx_1, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.qtgui_freq_sink_x_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200") ################################################## # Parameters ################################################## self.subdev = subdev self.devid = devid self.frequency = frequency self.fftsize = fftsize ################################################## # Variables ################################################## self.GUI_samp_rate = GUI_samp_rate = 10e6 self.samp_rate = samp_rate = int(GUI_samp_rate) self.prefix = prefix = "tpr_" self.text_samp_rate = text_samp_rate = GUI_samp_rate self.text_deviceID = text_deviceID = subdev self.text_Device_addr = text_Device_addr = devid self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = 1 self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.noise_amplitude = noise_amplitude = .5 self.integ = integ = 2 self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = 1 self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_noise = add_noise = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._GUI_samp_rate_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.GUI_samp_rate, callback=self.set_GUI_samp_rate, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=.1, v_offset=0, t_scale=100, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_2 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=GUI_samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=True, avg_alpha=.01, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=20, ref_scale=2.0, sample_rate=GUI_samp_rate, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((devid, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(GUI_samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) (self.uhd_usrp_source_0).set_processor_affinity([0]) self._text_samp_rate_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_samp_rate, callback=self.set_text_samp_rate, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1) self._text_deviceID_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_deviceID, callback=self.set_text_deviceID, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1) self._text_Device_addr_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_Device_addr, callback=self.set_text_Device_addr, label="Device Address", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1) (self.single_pole_iir_filter_xx_0).set_processor_affinity([1]) _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_amplitude_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, label='noise_amplitude', converter=forms.float_converter(), proportion=0, ) self._noise_amplitude_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, minimum=.01, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self._add_noise_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_noise, callback=self.set_add_noise, label="Noise Source", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1) ################################################## # Connections ################################################## self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="V/HF mult-imode transmitter") ################################################## # Variables ################################################## self.var_1 = var_1 = 145100000 self.var_text = var_text = var_1 self.tx_mode = tx_mode = 0, 0, 1 self.tx_freq = tx_freq = 1500, -1500, -1500 self.tune = tune = 0 self.side_band = side_band = 2 self.samp_rate = samp_rate = 1.515152e6 self.pwr = pwr = 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.0, 0, 0.11 self.lo_freq_Hz = lo_freq_Hz = (145.1e6, 145.11e6, 14.070e6, 14.236e6, 28.720e6, 10.0e6, 15.0e6, var_1) self.hi_lo = hi_lo = 1 self.freq_chooser = freq_chooser = 0 self.fine_tune = fine_tune = 0 self.chooser = chooser = 1 ################################################## # Blocks ################################################## _tune_sizer = wx.BoxSizer(wx.VERTICAL) self._tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, label="Coarse Tune", converter=forms.int_converter(), proportion=0, ) self._tune_slider = forms.slider( parent=self.GetWin(), sizer=_tune_sizer, value=self.tune, callback=self.set_tune, minimum=-61000, maximum=61000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.GridAdd(_tune_sizer, 3, 1, 1, 1) self._side_band_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.side_band, callback=self.set_side_band, label=" Sideband", choices=[0, 1, 2], labels=["LSB", "USB", "CW"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._side_band_chooser, 3, 2, 1, 1) self._hi_lo_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.hi_lo, callback=self.set_hi_lo, label="Power Level", choices=[1, 2], labels=["Low", "High"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._hi_lo_chooser, 4, 2, 1, 1) self._freq_chooser_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.freq_chooser, callback=self.set_freq_chooser, label="FREQUENCY SELECT", choices=[0, 1, 2, 3, 4, 5, 6, 7], labels=["145.100", "145.110", "14.070", "14.236", "28.720", "10", "15", "PRESET"], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._freq_chooser_chooser, 1, 1, 1, 1) _fine_tune_sizer = wx.BoxSizer(wx.VERTICAL) self._fine_tune_text_box = forms.text_box( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, label="Fine Tune", converter=forms.float_converter(), proportion=0, ) self._fine_tune_slider = forms.slider( parent=self.GetWin(), sizer=_fine_tune_sizer, value=self.fine_tune, callback=self.set_fine_tune, minimum=-5000 / 2, maximum=5000 / 2, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_fine_tune_sizer, 4, 1, 1, 1) self._chooser_chooser = forms.button( parent=self.GetWin(), value=self.chooser, callback=self.set_chooser, label="TX-RX Selector", choices=[1, 0], labels=["Receive", "Transmit"], ) self.GridAdd(self._chooser_chooser, 6, 1, 2, 1) self._var_text_static_text = forms.static_text( parent=self.GetWin(), value=self.var_text, callback=self.set_var_text, label="PRESET FREQUENCY", converter=forms.float_converter(), ) self.GridAdd(self._var_text_static_text, 1, 2, 1, 1) self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf(8, (), 100) self.pfb_interpolator_ccf_0.declare_sample_delay(0) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate / 4) self.osmosdr_sink_0.set_center_freq(lo_freq_Hz[freq_chooser] + tune + fine_tune - (tx_freq[side_band]), 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.fft_filter_xxx_0_0_0_0_0 = filter.fft_filter_fff( 1, (firdes.band_pass(1, samp_rate / 32, 250, 3500, 400)), 1 ) self.fft_filter_xxx_0_0_0_0_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 32, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0_0_0 = blocks.multiply_const_vcc(((pwr[freq_chooser] * hi_lo),)) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((40 * 10,)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_gr_complex * 1, open=bool(chooser)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=tx_mode[side_band], output_index=0, ) self.band_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.band_pass(1, 47348, 150, 1500, 300, firdes.WIN_HAMMING, 6.76) ) self.audio_source_0_0 = audio.source(47348, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate / 32, analog.GR_COS_WAVE, tx_freq[side_band], 1, 0) self.analog_const_source_x_0 = analog.sig_source_c(0, analog.GR_CONST_WAVE, 0, 0, (0.070) * 9) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.audio_source_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_multiply_const_vxx_1_0_0_0, 0)) self.connect((self.blks2_valve_1, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.fft_filter_xxx_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_0_0, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 1)) self.connect((self.fft_filter_xxx_0_0_0_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.pfb_interpolator_ccf_0, 0), (self.osmosdr_sink_0, 0))