def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3): gr.top_block.__init__(self, "Afsk Test") Qt.QWidget.__init__(self) self.setWindowTitle("Afsk Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "afsk_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.baud = baud = 1200 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.noise_amp = noise_amp = 0.3 self.mult = mult = (samp_rate)/2/3.141593 self.decim = decim = 2 self.bb_gain = bb_gain = .75 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #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) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: 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 = [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.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #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(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) 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( 2048, #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(True) 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) self.qtgui_time_sink_x_0.enable_stem_plot(False) 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(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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4,4,3,4) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-80, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Spectrum", #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(-140, 10) 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(True) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_layout.addWidget(self._pyqt_text_output_0_win) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0; self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_symb, sensitivity=0.06, bt=1, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("packet_len") self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0)) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=samp_rate, quad_rate=samp_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, addr='0.0.0.0', bb_gain=.4, rx_gain=20, tx_correct=0, tx_freq=433e6, tx_gain=20, tx_offset=50e3): gr.top_block.__init__(self, "MGS Rocksat Transceiver v2.0") Qt.QWidget.__init__(self) self.setWindowTitle("MGS Rocksat Transceiver v2.0") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fsk_trx_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.addr = addr self.bb_gain = bb_gain self.rx_gain = rx_gain self.tx_correct = tx_correct self.tx_freq = tx_freq self.tx_gain = tx_gain self.tx_offset = tx_offset ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500e3 self.baud = baud = 10e3 self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 433e6 self.mult = mult = (samp_rate) / 2 / 3.141593 self.decim = decim = 10 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq( uhd.tune_request(rx_freq, samp_rate / 2), 0) self.uhd_usrp_source_0_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0_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( uhd.tune_request(tx_freq + tx_correct, tx_offset), 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_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) 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(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.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim, #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_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(1.0) 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.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0 self.top_layout.addWidget(self._pyqt_text_input_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 15e3, 1000, firdes.WIN_HAMMING, 6.76)) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=48, postamble_bytes=10) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=256) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=50, bt=alpha, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", addr, '52003', 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_set_0 = blocks.pdu_set(pmt.intern("key"), pmt.intern("value")) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (bb_gain, )) self.blocks_message_debug_0 = blocks.message_debug() self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, gs_name='VTGS', ip='0.0.0.0', meta_rate=.1, port='52003', record_iq=0, record_rfo=0, record_snr=0, tx_freq=1265e6, tx_offset=250e3): gr.top_block.__init__(self, "VTGS Rocksat-X 2017 Transceiver v2.0") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat-X 2017 Transceiver v2.0") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "vtgs_trx_file") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gs_name = gs_name self.ip = ip self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.tx_freq = tx_freq self.tx_offset = tx_offset ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f") + '_UTC' self.samp_rate = samp_rate = 500e3 self.baud = baud = 125e3 self.snr_fn = snr_fn = "{:s}_{:s}.snr".format(gs_name, ts_str) self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.rfo_fn = rfo_fn = "{:s}_{:s}.rfo".format(gs_name, ts_str) self.iq_fn = iq_fn = "{:s}_{:s}_{:s}k.fc32".format( gs_name, ts_str, str(int(samp_rate) / 1000)) self.alpha = alpha = 0.5 self.uplink_label = uplink_label = '' self.tx_gain = tx_gain = 25 self.tx_correct = tx_correct = 2000 self.snr_fp = snr_fp = "/captures/rocksat/{:s}".format(snr_fn) self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 1 self.rx_freq_lbl = rx_freq_lbl = "{:4.3f}".format(rx_freq / 1e6) self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.rfo_fp = rfo_fp = "/captures/rocksat/{:s}".format(rfo_fn) self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.iq_fp = iq_fp = "/captures/rocksat/{:s}".format(iq_fn) self.bb_gain = bb_gain = .75 ################################################## # Blocks ################################################## self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 4, 8, 1, 4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 11, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._uplink_label_tool_bar = Qt.QToolBar(self) if None: self._uplink_label_formatter = None else: self._uplink_label_formatter = lambda x: str(x) self._uplink_label_tool_bar.addWidget(Qt.QLabel('TX MSG' + ": ")) self._uplink_label_label = Qt.QLabel( str(self._uplink_label_formatter(self.uplink_label))) self._uplink_label_tool_bar.addWidget(self._uplink_label_label) self.top_grid_layout.addWidget(self._uplink_label_tool_bar, 9, 8, 1, 1) self._tx_gain_range = Range(0, 86, 1, 25, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'TX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_gain_win, 10, 8, 1, 4) self._tx_correct_range = Range(-10000, 10000, 1, 2000, 200) self._tx_correct_win = RangeWidget(self._tx_correct_range, self.set_tx_correct, "tx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._tx_correct_win, 12, 8, 1, 4) self._rx_gain_range = Range(0, 86, 1, 1, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 3, 8, 1, 4) self._rx_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._rx_freq_lbl_formatter = None else: self._rx_freq_lbl_formatter = lambda x: str(x) self._rx_freq_lbl_tool_bar.addWidget(Qt.QLabel('RX Freq [MHz]' + ": ")) self._rx_freq_lbl_label = Qt.QLabel( str(self._rx_freq_lbl_formatter(self.rx_freq_lbl))) self._rx_freq_lbl_tool_bar.addWidget(self._rx_freq_lbl_label) self.top_grid_layout.addWidget(self._rx_freq_lbl_tool_bar, 0, 10, 1, 2) self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=8, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw '', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 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(-130, -20) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 5, 0, 4, 8) self.qtgui_number_sink_2 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_2.set_update_time(0.10) self.qtgui_number_sink_2.set_title("") labels = ['EVM', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("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_2.set_min(i, -1) self.qtgui_number_sink_2.set_max(i, 1) self.qtgui_number_sink_2.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_2.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_2.set_label(i, labels[i]) self.qtgui_number_sink_2.set_unit(i, units[i]) self.qtgui_number_sink_2.set_factor(i, factor[i]) self.qtgui_number_sink_2.enable_autoscale(False) self._qtgui_number_sink_2_win = sip.wrapinstance( self.qtgui_number_sink_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_2_win, 2, 8, 1, 4) self.qtgui_number_sink_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0.set_title("") labels = ['SNR', '', '', '', '', '', '', '', '', ''] units = ['dB', '', '', '', '', '', '', '', '', ''] colors = [("blue", "red"), ("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_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0.set_max(i, 30) self.qtgui_number_sink_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0.set_label( i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_win, 1, 8, 1, 4) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['RX Freq Offset', 'SNR', '', '', '', '', '', '', '', ''] units = ['Hz', 'dB', '', '', '', '', '', '', '', ''] 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, 0, 8, 1, 2) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / 10, #bw "TX Spectrum", #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(-140, 10) 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(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 9, 0, 4, 8) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-140, -20) 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] 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(2): 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, 5, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1, 1) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [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_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 5, 8, 4, 4) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0 self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 9, 9, 1, 3) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=50, bt=alpha, verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", ip, '52002', 1024, False) self.blocks_socket_pdu_0_1 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_nlog10_ff_0_1 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (bb_gain, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_moving_average_xx_0_0_1 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( 1000, 0.001, 4000) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 100000, 0.00001, 4000) self.blocks_keep_one_in_n_0_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate * meta_rate)) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, int(samp_rate / 8 * meta_rate)) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, '/captures/rocksat/testing/trimmed_500k.fc32', True) self.blocks_file_sink_1_0 = blocks.file_sink(gr.sizeof_float * 1, rfo_fp, False) self.blocks_file_sink_1_0.set_unbuffered(False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 1, snr_fp, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, iq_fp, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared( 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_snr), ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float * 1, num_inputs=1, num_outputs=2, input_index=0, output_index=int(record_rfo), ) 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=int(record_iq), ) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 125e3, 1, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_1, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0_1, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_selector_0, 1), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blks2_selector_0_0, 1), (self.blocks_file_sink_1_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 1), (self.blocks_file_sink_1, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_2, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_nlog10_ff_0_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blocks_keep_one_in_n_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_keep_one_in_n_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_moving_average_xx_0_0_1, 0), (self.qtgui_number_sink_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_nlog10_ff_0_1, 0), (self.blocks_moving_average_xx_0_0_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self, puncpat='11'): gr.top_block.__init__(self, "Outernet Flatsat Flowgraph") Qt.QWidget.__init__(self) self.setWindowTitle("Outernet Flatsat Flowgraph") 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()) ################################################## # Parameters ################################################## self.puncpat = puncpat ################################################## # Variables ################################################## self.rate = rate = 2 self.polys = polys = [79, 109] self.k = k = 7 self.frame_size = frame_size = 32 self.uhd_samp_rate = uhd_samp_rate = 614400 self.tx_gain = tx_gain = 0 self.samples_per_symbol = samples_per_symbol = 64 self.rx_gain = rx_gain = 0 self.rf_tx_freq = rf_tx_freq = 145e6 self.rf_rx_freq = rf_rx_freq = 401e6 self.rf_offset_freq = rf_offset_freq = 80e3 self.rf_bw = rf_bw = 100e3 self.interleave = interleave = 4 self.dec_cc = dec_cc = fec.cc_decoder.make(frame_size, k, rate, (polys), 0, -1, fec.CC_STREAMING, False) ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 90, 1, 0, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "TX Gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self._rx_gain_range = Range(0, 90, 1, 0, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, "RX Gain", "counter_slider", float) self.top_layout.addWidget(self._rx_gain_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(uhd_samp_rate) self.uhd_usrp_source_0.set_center_freq(rf_rx_freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_bandwidth(rf_bw, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(uhd_samp_rate) self.uhd_usrp_sink_0.set_center_freq(rf_tx_freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_bandwidth(rf_bw, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=8, decimation=1, taps=None, fractional_bw=0.125, ) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0; self.top_layout.addWidget(self._pyqt_text_input_0_win) self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec_cc, threading= None, ann=None, puncpat=puncpat, integration_period=10000) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x00, 16) self.digital_map_bb_0 = digital.map_bb(([-1, 1])) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=8, bt=0.5, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=samples_per_symbol, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.ccsds_rs_decode_pdu_0 = ccsds.rs_decode_pdu(interleave) self.ccsds_asm_deframer_pdu_0 = ccsds.asm_deframer_pdu(0, interleave, 1, 255) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, "packet_len", 64*8) self.blocks_socket_pdu_1_0 = blocks.socket_pdu("TCP_CLIENT", "127.0.0.1", "51423", 892, False) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_message_debug_0_1 = blocks.message_debug() self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(0) self.ax25_encode_heir_0_0 = ax25_encode_heir( destination_callsign="PICASS", destination_ssid=0, post_flag_quantity=16, post_sync_quantity=16, pre_flag_quantity=16, pre_sync_quantity=128, source_callsign="BISAGS ", source_ssid=14, sync_value=85, ) self.ais_invert_0 = ais.invert() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.ax25_encode_heir_0_0, 'pdus in')) self.msg_connect((self.blocks_socket_pdu_1_0, 'pdus'), (self.blocks_message_debug_0_1, 'print_pdu')) self.msg_connect((self.ccsds_asm_deframer_pdu_0, 'pdus'), (self.ccsds_rs_decode_pdu_0, 'pdu_in')) self.msg_connect((self.ccsds_rs_decode_pdu_0, 'pdu_out'), (self.blocks_socket_pdu_1_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.ax25_encode_heir_0_0, 'pdus in')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.blocks_message_debug_0_1, 'print_pdu')) self.connect((self.ais_invert_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.ax25_encode_heir_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ax25_nrzi_encoder_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.ais_invert_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.ccsds_asm_deframer_pdu_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_gmsk_demod_0, 0))