def create_header_blocks(self): hdr_format = digital.header_format_ofdm(self.occupied_carriers, 1, self.len_tag_key) self.protocol_formatter = digital.protocol_formatter_bb(hdr_format, self.len_tag_key) self.repack_bits_hdr = blocks.repack_bits_bb(8, self.header_const.bits_per_symbol(), self.len_tag_key, True, gr.GR_LSB_FIRST) self.hdr_modulation = digital.chunks_to_symbols_bc(self.header_const.points(), 1)
def create_header_blocks(self): hdr_format = digital.header_format_ofdm(self.occupied_carriers, 1, self.len_tag_key) self.protocol_formatter = digital.protocol_formatter_bb( hdr_format, self.len_tag_key) self.repack_bits_hdr = blocks.repack_bits_bb( 8, self.header_const.bits_per_symbol(), self.len_tag_key, True, gr.GR_LSB_FIRST) self.hdr_modulation = digital.chunks_to_symbols_bc( self.header_const.points(), 1)
def __init__(self, length_tag_key="package_size", mod_encabezado=digital.constellation_bpsk(), occupied_carriers=(range(-27, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 28), ), package_size=96): gr.hier_block2.__init__( self, "HeaderModulator", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.length_tag_key = length_tag_key self.mod_encabezado = mod_encabezado self.occupied_carriers = occupied_carriers self.package_size = package_size ################################################## # Variables ################################################## self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) ################################################## # Blocks ################################################## self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (mod_encabezado.points()), 1) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, package_size, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) ################################################## # Connections ################################################## self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") 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", "ofdm_tx_virtualsource_qt") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 100000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 96 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #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(False) 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 = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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: 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_grid_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, #bw 'FFT Plot', #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(False) 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) 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(-2, 2) 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(False) 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) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, "Rx'd Packets", "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self): gr.top_block.__init__(self, "SECUNDARY") Qt.QWidget.__init__(self) self.setWindowTitle("SECUNDARY") 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", "secundary") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_bpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.length_tag_key = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.tx_gain = tx_gain = 50 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 1000000 self.rx_gain = rx_gain = 50 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) ################################################## # Blocks ################################################## self._tx_gain_tool_bar = Qt.QToolBar(self) self._tx_gain_tool_bar.addWidget(Qt.QLabel('tx_gain' + ": ")) self._tx_gain_line_edit = Qt.QLineEdit(str(self.tx_gain)) self._tx_gain_tool_bar.addWidget(self._tx_gain_line_edit) self._tx_gain_line_edit.returnPressed.connect(lambda: self.set_tx_gain( eng_notation.str_to_num(str(self._tx_gain_line_edit.text())))) self.top_layout.addWidget(self._tx_gain_tool_bar) self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel('rx_gain' + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num(str(self._rx_gain_line_edit.text())))) self.top_layout.addWidget(self._rx_gain_tool_bar) self.uhd_usrp_source_0_0_1 = uhd.usrp_source( ",".join(('serial=F5C243', "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0_0_1.set_center_freq(2400000000, 0) self.uhd_usrp_source_0_0_1.set_gain(rx_gain, 0) self.uhd_usrp_source_0_0_1.set_antenna('RX2', 0) self.uhd_usrp_source_0_0_1.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0_1.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(('serial=F5C234', "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0_0.set_center_freq(2450000000, 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_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(('serial=F5C234', "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), length_tag_key, ) self.uhd_usrp_sink_0_0.set_center_freq(2400000000, 0) self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('serial=F5C243', "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), length_tag_key, ) self.uhd_usrp_sink_0.set_center_freq(2450000000, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec()) self.qtgui_sink_x_0_0 = qtgui.sink_c( 64, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 4000000000, #fc 50000, #bw 'SECUNDARY RX', #name True, #plotfreq True, #plotwaterfall True, #plottime True #plotconst ) self.qtgui_sink_x_0_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_0_win = sip.wrapinstance( self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget) self.qtgui_sink_x_0_0.enable_rf_freq(False) self.top_layout.addWidget(self._qtgui_sink_x_0_0_win) self.fft_vxx_1_0_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0_0_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.epy_block_0_0 = epy_block_0_0.mac() self.epy_block_0 = epy_block_0.mac() self.digital_protocol_formatter_bb_0_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_packet_headerparser_b_0_0_0_0_0_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_packet_headerparser_b_0_0_0_0_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_sync_sc_cfb_0_0_0_0_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_payload_0_0_0_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header_0_0_0_0_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_serializer_vcc_header_0_0_0_0 = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len // 4, rolloff, length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len // 4, rolloff, length_tag_key) self.digital_ofdm_chanest_vcvc_0_0_0_0_0_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_chanest_vcvc_0_0_0_0_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_header_payload_demux_0_0_0_0_0_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_header_payload_demux_0_0_0_0_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_constellation_decoder_cb_1_0_0_0_0_0 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_1_0_0_0_0 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0_0_0_0_0_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_constellation_decoder_cb_0_0_0_0_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_1 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_tagged_stream_to_pdu_0_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, length_tag_key) self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, length_tag_key) self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, True) self.blocks_tag_gate_0_0.set_single_key("") self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, True) self.blocks_tag_gate_0.set_single_key("") self.blocks_repack_bits_bb_0_2_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_2 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_1_0_0_0_0_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_1_0_0_0_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0_1_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0_1 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, length_tag_key) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, length_tag_key) self.blocks_multiply_xx_0_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(50e-3) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(50e-3) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.intern("TEST"), 1000) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_delay_0_0_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.analog_frequency_modulator_fc_0_0_0_0_0_0 = analog.frequency_modulator_fc( -2.0 / fft_len) self.analog_frequency_modulator_fc_0_0_0_0_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.epy_block_0_0, 'time_unit')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.epy_block_0_0, 'ack')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0, 'pdus'), (self.epy_block_0, 'packet')) self.msg_connect( (self.digital_packet_headerparser_b_0_0_0_0_0, 'header_data'), (self.digital_header_payload_demux_0_0_0_0_0, 'header_data')) self.msg_connect( (self.digital_packet_headerparser_b_0_0_0_0_0_0, 'header_data'), (self.digital_header_payload_demux_0_0_0_0_0_0, 'header_data')) self.msg_connect((self.epy_block_0, 'ack'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.epy_block_0_0, 'transmit_packet'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.epy_block_0_0, 'channel_up'), (self.uhd_usrp_sink_0_0, 'command')) self.msg_connect((self.epy_block_0_0, 'channel_down'), (self.uhd_usrp_source_0_0, 'command')) self.connect((self.analog_frequency_modulator_fc_0_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_0, 0)) self.connect((self.analog_frequency_modulator_fc_0_0_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_0_0, 0)) self.connect((self.blocks_delay_0_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_0, 1)) self.connect((self.blocks_delay_0_0_0_0_0_0, 0), (self.blocks_multiply_xx_0_0_0_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0), (self.digital_header_payload_demux_0_0_0_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0), (self.digital_header_payload_demux_0_0_0_0_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0_2, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.blocks_repack_bits_bb_0_2_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.digital_protocol_formatter_bb_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_1, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_1_0, 0), (self.digital_chunks_to_symbols_xx_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_1_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1_0_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_2, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_2_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tag_gate_0_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_tagged_stream_mux_0_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.blocks_tagged_stream_mux_0_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_1, 0), (self.blocks_tagged_stream_mux_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0, 0), (self.digital_packet_headerparser_b_0_0_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0_0, 0), (self.digital_packet_headerparser_b_0_0_0_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_1_0_0_0_0, 0), (self.blocks_repack_bits_bb_0_1_0_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_1_0_0_0_0_0, 0), (self.blocks_repack_bits_bb_0_1_0_0_0_0_0, 0)) self.connect((self.digital_header_payload_demux_0_0_0_0_0, 0), (self.fft_vxx_0_0_0_0_0_0, 0)) self.connect((self.digital_header_payload_demux_0_0_0_0_0, 1), (self.fft_vxx_1_0_0_0_0, 0)) self.connect((self.digital_header_payload_demux_0_0_0_0_0_0, 0), (self.fft_vxx_0_0_0_0_0_0_0, 0)) self.connect((self.digital_header_payload_demux_0_0_0_0_0_0, 1), (self.fft_vxx_1_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0_0_0_0_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0_0_0_0_0_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0, 0), (self.digital_ofdm_serializer_vcc_header_0_0_0_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0, 0), (self.digital_ofdm_serializer_vcc_header_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0, 0), (self.digital_ofdm_serializer_vcc_payload_0_0_0_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0, 0), (self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_0_0_0_0, 0), (self.digital_constellation_decoder_cb_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_0_0_0_0_0, 0), (self.digital_constellation_decoder_cb_0_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_0_0_0_0, 0), (self.digital_constellation_decoder_cb_1_0_0_0_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0, 0), (self.digital_constellation_decoder_cb_1_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 0), (self.analog_frequency_modulator_fc_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 1), (self.digital_header_payload_demux_0_0_0_0_0, 1)) self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 0), (self.analog_frequency_modulator_fc_0_0_0_0_0_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 1), (self.digital_header_payload_demux_0_0_0_0_0_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_1, 0)) self.connect((self.digital_protocol_formatter_bb_0_0, 0), (self.blocks_repack_bits_bb_0_0_1_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0)) self.connect((self.fft_vxx_0_0_0_0_0_0, 0), (self.digital_ofdm_chanest_vcvc_0_0_0_0_0, 0)) self.connect((self.fft_vxx_0_0_0_0_0_0_0, 0), (self.digital_ofdm_chanest_vcvc_0_0_0_0_0_0, 0)) self.connect((self.fft_vxx_1_0_0_0_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0, 0)) self.connect((self.fft_vxx_1_0_0_0_0_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_delay_0_0_0_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0_0_1, 0), (self.blocks_delay_0_0_0_0_0_0, 0)) self.connect((self.uhd_usrp_source_0_0_1, 0), (self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Novo") Qt.QWidget.__init__(self) self.setWindowTitle("Novo") 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", "novo") self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 2 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.Const_HDR = Const_HDR = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_HDR.gen_soft_dec_lut(8) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts self.rxmod = rxmod = digital.generic_mod(Const_HDR, False, sps, True, eb, False, False) self.preamble = preamble = [ 0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc ] self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119] self.snc_threshold = snc_threshold = 0.9 self.samp_rate = samp_rate = 32000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, sps * nfilts, 1.0, eb, 11 * sps * nfilts) self.packet_len_tag_key = packet_len_tag_key = "packet_length" self.packet_len = packet_len = 100 self.ntaps = ntaps = len(tx_rrc_taps) self.noise_voltage = noise_voltage = 1 self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), (preamble), ([1])) self.mark_delay = mark_delay = mark_delays[sps] self.hdr_format = hdr_format = digital.header_format_default( digital.packet_utils.default_access_code, 1, 1) self.freq_offset = freq_offset = 0 self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2 self.enc_hdr = enc_hdr = fec.dummy_encoder_make(8000) self.enc = enc = fec.dummy_encoder_make(8000) self.dec_hdr = dec_hdr = fec.dummy_decoder.make(8000) self.Const_PLD = Const_PLD = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_PLD.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self._noise_voltage_range = Range(0, 8, .05, 1, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, 'Noise Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_voltage_win) self._freq_offset_range = Range(-30, 30, .1, 0, 200) self._freq_offset_win = RangeWidget( self._freq_offset_range, self.set_freq_offset, 'Frequency Offset (Multiples of Sub-carrier spacing)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win) self._snc_threshold_range = Range(0, 1, .05, 0.9, 200) self._snc_threshold_win = RangeWidget(self._snc_threshold_range, self.set_snc_threshold, 'S&C Threshold', "counter_slider", float) self.top_grid_layout.addWidget(self._snc_threshold_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( packet_len * 3, #size samp_rate, #samp_rate 'Tx Data', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 256) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, '') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( packet_len * 2, #size samp_rate, #samp_rate 'Rx Data', #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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_length_tag_key') 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) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Rx Spectrum', #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(-60, 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 = ['Rx Spectrum', '', '', '', '', '', '', '', '', ''] 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(filt_delay) self.digital_protocol_parser_b_0 = digital.protocol_parser_b( hdr_format) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, packet_len_tag_key) self.digital_pfb_clock_sync_xxx_0_1 = digital.pfb_clock_sync_ccf( sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_map_bb_1_0 = digital.map_bb((Const_PLD.pre_diff_code())) self.digital_map_bb_1 = digital.map_bb((Const_HDR.pre_diff_code())) self.digital_header_payload_demux_0 = digital.header_payload_demux( hdr_format.header_nbits() / Const_HDR.bits_per_symbol(), 1, 0, "payload symbols", "time_est", True, gr.sizeof_gr_complex, "rx_time", sps, "", 0, ) self.digital_corr_est_cc_0_0 = digital.corr_est_cc( (modulated_sync_word), 1, mark_delay, 0.999) self.digital_constellation_soft_decoder_cf_0_1 = digital.constellation_soft_decoder_cf( Const_PLD) self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf( Const_HDR) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (Const_PLD.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (Const_HDR.points()), 1) self.digital_burst_shaper_xx_0_0 = digital.burst_shaper_cc( (firdes.window(firdes.WIN_HANN, 20, 0)), 0, filt_delay, True, packet_len_tag_key) (self.digital_burst_shaper_xx_0_0).set_block_alias("burst_shaper0") self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.channels_channel_model_0 = channels.channel_model( noise_voltage=0, frequency_offset=freq_offset * 1.0 / packet_len, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_len_tag_key, 0) self.blocks_tagged_stream_multiply_length_0_1 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, packet_len_tag_key, sps) self.blocks_tag_debug_0_0_0 = blocks.tag_debug(gr.sizeof_char * 1, 'TAGGED', "") self.blocks_tag_debug_0_0_0.set_display(True) self.blocks_tag_debug_0_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, 'MUX', "") self.blocks_tag_debug_0_0.set_display(True) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_len_tag_key) self.blocks_repack_bits_bb_1_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, Const_PLD.bits_per_symbol(), packet_len_tag_key, False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, Const_HDR.bits_per_symbol(), packet_len_tag_key, False, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/trasmit_1_mb.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, 'depois.txt', False) self.blocks_file_sink_0_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.digital_protocol_parser_b_0, 'info'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.blocks_char_to_float_1_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_char_to_float_1_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_file_sink_0_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_1_0, 0), (self.digital_protocol_parser_b_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_1, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tag_debug_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_burst_shaper_xx_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_corr_est_cc_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.blocks_repack_bits_bb_1_0, 0)) self.connect((self.digital_burst_shaper_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_soft_decoder_cf_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_constellation_soft_decoder_cf_0_1, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_corr_est_cc_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.digital_constellation_soft_decoder_cf_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.digital_constellation_soft_decoder_cf_0_1, 0)) self.connect((self.digital_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_1, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tag_debug_0_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_1, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 1000000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 96 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.fft_len = fft_len = 64 self.band_width = band_width = 20000000 ################################################## # Blocks ################################################## self.pluto_sink_0 = iio.pluto_sink('193.168.2.1', 500000000, samp_rate, band_width, 0x8000, False, 10.0, '', True) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char * 1, '0.0.0.0', 1234, 1472, True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, "Rx'd Packets", "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.pluto_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") 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", "tx_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.samp_rate = samp_rate = 100000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, length_tag_key,) ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 20, #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_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(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_0_0 = qtgui.time_sink_f( 200, #size samp_rate, #samp_rate "É ESTE", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #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(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 = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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: 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.meu_qpsk_modulator_adapt_cb_0 = meu.qpsk_modulator_adapt_cb() self.meu_qpsk_demod_adapt_cb_0 = meu.qpsk_demod_adapt_cb() self.meu_phase_finder_vci_0 = meu.phase_finder_vci(fft_len/4, fft_len) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), fft_len/4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), fft_len/4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len+fft_len/4, rolloff, length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len/4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0, ) self.digital_crc32_bb_0_0 = digital.crc32_bb(True, packet_length_tag_key, False) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=100e-12, frequency_offset=1, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=True ) self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char*1, 'Rx Bytes', ""); self.blocks_tag_debug_1.set_display(True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex*1, '', ""); self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000)), True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0/fft_len) self.analog_const_source_x_0_0 = analog.sig_source_i(0, analog.GR_CONST_WAVE, 0, 0, 1) self.analog_const_source_x_0 = analog.sig_source_i(0, analog.GR_CONST_WAVE, 0, 0, 1) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_const_source_x_0, 0), (self.meu_qpsk_modulator_adapt_cb_0, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.meu_qpsk_demod_adapt_cb_0, 1)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_int_to_float_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.meu_qpsk_modulator_adapt_cb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.meu_phase_finder_vci_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.meu_qpsk_demod_adapt_cb_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.meu_phase_finder_vci_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.meu_qpsk_demod_adapt_cb_0, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) self.connect((self.meu_qpsk_modulator_adapt_cb_0, 0), (self.blocks_tagged_stream_mux_0, 1))
def __init__(self, header_format=digital.header_format_default( digital.packet_utils.default_access_code, 0), length_tag_name='packet_len'): gr.top_block.__init__(self, "Fsk Msg") Qt.QWidget.__init__(self) self.setWindowTitle("Fsk Msg") 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_msg") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.header_format = header_format self.length_tag_name = length_tag_name ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '', False, False, '') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win) self.epy_block_0 = epy_block_0.msg_block() self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( header_format, length_tag_name) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, length_tag_name, 0) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.epy_block_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.epy_block_0, 'msg_in')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0))
def __init__(self): gr.top_block.__init__(self, "Split 1") ################################################## # Variables ################################################## self.pilot_carriers = pilot_carriers = ((-27, -14, -7, 7, 14, 27),) self.pattern2 = pattern2 = [1, -1, 1, -1] self.pattern1 = pattern1 = [0., 1.41421356, 0., -1.41421356] self.occupied_carriers = occupied_carriers = (sorted(tuple(set([x for x in range(-26, 27)]) - set(pilot_carriers[0]) - set([0,]))),) self.fft_len = fft_len = 64 self.zcpu = zcpu = psutil self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('default') try: xmlrpcport = self._xmlrpcport_config.getint("split1", "xmlrpcport") except: xmlrpcport = 8080 self.xmlrpcport = xmlrpcport self._usrpip_config = ConfigParser.ConfigParser() self._usrpip_config.read('./default') try: usrpip = self._usrpip_config.get("usrp_hydra", "ip") except: usrpip = "127.0.0.1" self.usrpip = usrpip self._timeout_config = ConfigParser.ConfigParser() self._timeout_config.read('./default') try: timeout = self._timeout_config.getint("global", "zmqtimeout") except: timeout = 100 self.timeout = timeout self.sync_word2 = sync_word2 = [0., 0., 0., 0., 0., 0.,] + pattern2 * ((fft_len-12)/len(pattern2)) +[0., 0., 0., 0., 0., 0.,] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0.,] + pattern1 * ((fft_len-12)/len(pattern1)) +[0., 0., 0., 0., 0., 0.,] self._rxport_config = ConfigParser.ConfigParser() self._rxport_config.read('./default') try: rxport = self._rxport_config.get("usrp_hydra", "rxport1") except: rxport = "2666" self.rxport = rxport self.rateRx = rateRx = 0 self.rate1 = rate1 = 0 self.rate0 = rate0 = 0 self.pilot_symbols = pilot_symbols = ((-1,1, 1, -1, -1, -1),) self._payloadport_config = ConfigParser.ConfigParser() self._payloadport_config.read('./default') try: payloadport = self._payloadport_config.get("split1", "payloadport") except: payloadport = "2101" self.payloadport = payloadport self.payload_mod = payload_mod = digital.constellation_bpsk() self._maxnoutput_config = ConfigParser.ConfigParser() self._maxnoutput_config.read('./default') try: maxnoutput = self._maxnoutput_config.getint("global", "maxnoutput") except: maxnoutput = 100 self.maxnoutput = maxnoutput self.iq_rxrate = iq_rxrate = 0 self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("split1", "ip") except: ip = "127.0.0.1" self.ip = ip self._headerport_config = ConfigParser.ConfigParser() self._headerport_config.read('./default') try: headerport = self._headerport_config.get("split1", "headerport") except: headerport = "2100" self.headerport = headerport self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, "packet_len",) self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.probe1_1_0 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.probe1_1 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.probe1_0 = blocks.probe_rate(gr.sizeof_char*1, 500.0, 0.15) self.ziq_rxrate = blocks.probe_rate(gr.sizeof_gr_complex*1, 2000, 0.15) self.zeromq_push_sink_1 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ip + ":" + payloadport, timeout, True, -1) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ip + ":" + headerport, timeout, True, -1) self.zeromq_pull_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://" + usrpip + ":" + rxport, 100, True, -1) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', xmlrpcport), allow_none=True) self.xmlrpc_server_0.register_instance(self) self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever) self.xmlrpc_server_0_thread.daemon = True self.xmlrpc_server_0_thread.start() def _rateRx_probe(): while True: val = self.probe1_1_0.rate() try: self.set_rateRx(val) except AttributeError: pass time.sleep(1.0 / (10)) _rateRx_thread = threading.Thread(target=_rateRx_probe) _rateRx_thread.daemon = True _rateRx_thread.start() def _rate1_probe(): while True: val = self.probe1_1.rate() try: self.set_rate1(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate1_thread = threading.Thread(target=_rate1_probe) _rate1_thread.daemon = True _rate1_thread.start() def _rate0_probe(): while True: val = self.probe1_0.rate() try: self.set_rate0(val) except AttributeError: pass time.sleep(1.0 / (10)) _rate0_thread = threading.Thread(target=_rate0_probe) _rate0_thread.daemon = True _rate0_thread.start() def _iq_rxrate_probe(): while True: val = self.ziq_rxrate.rate() try: self.set_iq_rxrate(val) except AttributeError: pass time.sleep(1.0 / (10)) _iq_rxrate_thread = threading.Thread(target=_iq_rxrate_probe) _iq_rxrate_thread.daemon = True _iq_rxrate_thread.start() self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, "packet_len") self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=16, frame_length_tag_key='frame_'+"packet_len", packet_length_tag_key="packet_len", occupied_carriers=occupied_carriers, pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=1, debug_log=False, scramble_bits=False ) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len", True) def _cpu_percent_probe(): while True: val = self.zcpu.cpu_percent() try: self.set_cpu_percent(val) except AttributeError: pass time.sleep(1.0 / (1)) _cpu_percent_thread = threading.Thread(target=_cpu_percent_probe) _cpu_percent_thread.daemon = True _cpu_percent_thread.start() self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char*1, 200e3,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 200e3,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "RX'd Packets", ""); self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 100, "packet_len") self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, 1, "packet_len", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), "packet_len", False, gr.GR_LSB_FIRST) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 100, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.probe1_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.probe1_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_1, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.probe1_1_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.ziq_rxrate, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") 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", "tx_ofdm_updated") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_bpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)),) self.length_tag_key = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.tx_probe = tx_probe = 0 self.sync_word2_0 = sync_word2_0 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j] self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.sync_word1_0 = sync_word1_0 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.samp_rate = samp_rate = 50000 self.rx_probe = rx_probe = 0 self.rolloff = rolloff = 0 self.pilot_symbols_0 = pilot_symbols_0 = ((1, 1, 1, -1,),) self.pilot_carriers_0 = pilot_carriers_0 = ((-21, -7, 7, 21,),) self.payload_mod_0 = payload_mod_0 = digital.constellation_qpsk() self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len_0 = packet_len_0 = 96 self.packet_len = packet_len = 96 self.output_signal = output_signal = 0 self.og_signal_probe = og_signal_probe = 0 self.occupied_carriers_0 = occupied_carriers_0 = (list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)),) self.length_tag_key_0 = length_tag_key_0 = "frame_len" self.input_signal = input_signal = 0 self.header_mod_0 = header_mod_0 = digital.constellation_bpsk() self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, length_tag_key,) self.fft_len_0 = fft_len_0 = 64 self.decoded_probe = decoded_probe = 0 ################################################## # Blocks ################################################## self.blocks_probe_signal_x_4 = blocks.probe_signal_c() self.blocks_probe_signal_x_3 = blocks.probe_signal_c() self.blocks_probe_signal_x_2 = blocks.probe_signal_b() self.blocks_probe_signal_x_0_1 = blocks.probe_signal_b() self.blocks_probe_signal_x_0_0_0 = blocks.probe_signal_c() self.blocks_probe_signal_x_0_0 = blocks.probe_signal_c() def _tx_probe_probe(): global transmitted_data while True: val = self.blocks_probe_signal_x_0_0.level() transmitted_data = val try: self.set_tx_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _tx_probe_thread = threading.Thread(target=_tx_probe_probe) _tx_probe_thread.daemon = True _tx_probe_thread.start() def _rx_probe_probe(): global received_data while True: val = self.blocks_probe_signal_x_3.level() received_data = val try: self.set_rx_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _rx_probe_thread = threading.Thread(target=_rx_probe_probe) _rx_probe_thread.daemon = True _rx_probe_thread.start() self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #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(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(False) 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) labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): 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_grid_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, #bw 'FFT Plot', #name 1 ) 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(False) 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) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_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) def _output_signal_probe(): global output_data while True: val = self.blocks_probe_signal_x_0_1.level() output_data = val try: self.set_output_signal(val) except AttributeError: pass # time.sleep(1.0 / (10)) time.sleep(0.0911) _output_signal_thread = threading.Thread(target=_output_signal_probe) _output_signal_thread.daemon = True _output_signal_thread.start() def _og_signal_probe_probe(): global encoded_data while True: val = self.blocks_probe_signal_x_0_0_0.level() encoded_data = val try: self.set_og_signal_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _og_signal_probe_thread = threading.Thread(target=_og_signal_probe_probe) _og_signal_probe_thread.daemon = True _og_signal_probe_thread.start() def _input_signal_probe(): global input_data while True: val = self.blocks_probe_signal_x_2.level() input_data = val try: self.set_input_signal(val) except AttributeError: pass time.sleep(1.0 / (10)) _input_signal_thread = threading.Thread(target=_input_signal_probe) _input_signal_thread.daemon = True _input_signal_thread.start() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len//4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), fft_len//4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), fft_len//4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len + fft_len//4, rolloff, length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len//4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_crc32_bb_0_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1) def _decoded_probe_probe(): global decoded_signal while True: val = self.blocks_probe_signal_x_4.level() decoded_signal = val try: self.set_decoded_probe(val) except AttributeError: pass # time.sleep(1.0 / (10)) time.sleep(0.0911) _decoded_probe_thread = threading.Thread(target=_decoded_probe_probe) _decoded_probe_thread.daemon = True _decoded_probe_thread.start() self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.15, frequency_offset=0 * 1.0/fft_len, epsilon=1.0, taps=[1.0 + 1.0j], noise_seed=0, block_tags=True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char*1, 'Rx Bytes', "") self.blocks_tag_debug_1.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len//4) self.analog_random_source_x_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 255, 1000))), True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0/fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, u'header_data'), (self.digital_header_payload_demux_0, u'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_probe_signal_x_2, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.blocks_probe_signal_x_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_probe_signal_x_0_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_probe_signal_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_probe_signal_x_3, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.blocks_probe_signal_x_4, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
def __init__(self, input_port_num="55555", output_port_num="55556", rx_bw=0.5e6, rx_freq=2e9, rx_gain=0.8, serial_num="31C9237", tx_bw=0.5e6, tx_freq=2.0e9, tx_gain=1): gr.top_block.__init__(self, "tranceiver_ofdm_usrp") Qt.QWidget.__init__(self) self.setWindowTitle("tranceiver_ofdm_usrp") 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", "tranceiver_ofdm_usrp") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.input_port_num = input_port_num self.output_port_num = output_port_num self.rx_bw = rx_bw self.rx_freq = rx_freq self.rx_gain = rx_gain self.serial_num = serial_num self.tx_bw = tx_bw self.tx_freq = tx_freq self.tx_gain = tx_gain ################################################## # Variables ################################################## self.rep = rep = 3 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 10000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 256 self.out_buf_size = out_buf_size = 15000 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.enc_rep = enc_rep = fec.repetition_encoder_make(8000, rep) self.dec_rep = dec_rep = fec.repetition_decoder.make(8000, rep, 0.5) self.FEC_rate = FEC_rate = 1 / 2 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source( gr.sizeof_char, 1, "tcp://127.0.0.1:" + input_port_num, 100, False, -1, '') self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, "tcp://127.0.0.1:55556", 100, False, -1, '') self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_samp_rate(rx_bw) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_power_reference(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), packet_length_tag_key, ) self.uhd_usrp_sink_0.set_samp_rate(tx_bw) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_power_reference(tx_gain, 0) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fec_async_encoder_0 = fec.async_encoder(enc_rep, True, True, True, 1500) self.fec_async_decoder_0 = fec.async_decoder(dec_rep, True, True, 1500) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, packet_length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_1.set_min_output_buffer(15000) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_frame_equalizer_vcvc_0.set_min_output_buffer(15000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len // 4, rolloff, packet_length_tag_key) self.digital_ofdm_cyclic_prefixer_0.set_min_output_buffer(15000) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key, True) self.digital_ofdm_carrier_allocator_cvc_0.set_min_output_buffer(15000) self.digital_map_bb_0 = digital.map_bb([-1, 1]) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_header_payload_demux_0.set_min_output_buffer(15000) self.digital_crc32_bb_0_0 = digital.crc32_bb(False, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu( blocks.float_t, packet_length_tag_key) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, packet_length_tag_key) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self.blocks_repack_bits_bb_0_3_1 = blocks.repack_bits_bb( 8, 1, 'packet_len', True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, packet_length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, packet_length_tag_key) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, packet_length_tag_key) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_file_sink_0_0_0_0_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/root/repos/usrp-utils/archive/post_encoding.bin', False) self.blocks_file_sink_0_0_0_0_0_0_0.set_unbuffered(True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.fec_async_encoder_0, 'in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.fec_async_encoder_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.blocks_tagged_stream_to_pdu_1, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_sink_0_0_0_0_0_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_repack_bits_bb_0_3_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_3_1, 0), (self.digital_map_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 100000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 478 self.mysamp_rate = mysamp_rate = 50000000 self.min_singnal_var0 = min_singnal_var0 = 0 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.gain = gain = 0 self.fft_len = fft_len = 64 self.N_fft = N_fft = 1024 ################################################## # Blocks ################################################## self.min_signal0 = blocks.probe_signal_f() def _min_singnal_var0_probe(): while True: val = self.min_signal0.level() try: self.set_min_singnal_var0(val) except AttributeError: pass time.sleep(1.0 / (10)) _min_singnal_var0_thread = threading.Thread( target=_min_singnal_var0_probe) _min_singnal_var0_thread.daemon = True _min_singnal_var0_thread.start() self._gain_range = Range(0, 74, 1, 0, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=31DDABF", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(10e6) self.uhd_usrp_source_0.set_center_freq(2.402e9, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('serial= 31DDAA6', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(3000000) self.uhd_usrp_sink_0.set_center_freq(1E9, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #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(False) 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 = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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: 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_grid_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, #bw 'FFT Plot', #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(False) 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_1 = fft.fft_vcc(N_fft, True, (window.blackmanharris(N_fft)), False, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, N_fft) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, N_fft) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, -1 * min_singnal_var0) self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc( (0.05, )) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff( (N_fft / 50e6, )) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff( (N_fft / 50e6, )) self.blocks_min_xx_0 = blocks.min_ff(N_fft, 1) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( N_fft) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_min_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_min_xx_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.min_signal0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0_2, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "BFSK") Qt.QWidget.__init__(self) self.setWindowTitle("BFSK") 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", "top_block") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.hdr_format = hdr_format ################################################## # Variables ################################################## self.freq_symbol_1 = freq_symbol_1 = 10584 self.freq_symbol_0 = freq_symbol_0 = 8820 self.samp_rate = samp_rate = 44.1e3 self.fsk_deviation_hz = fsk_deviation_hz = freq_symbol_1 - freq_symbol_0 self.filter_taps = filter_taps = firdes.low_pass( 1.0, samp_rate, fsk_deviation_hz, 400) self.SPS = SPS = 200 ################################################## # Blocks ################################################## 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(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) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf( 1, filter_taps, (freq_symbol_1 + freq_symbol_0) / 2, samp_rate) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 6, 'len_key2') self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( SPS, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0), True, 1, []) self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'len_key2') self.blocks_tagged_stream_mux_1 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 147, 'len_key') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 100, 'len_key') self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, SPS) self.blocks_repack_bits_bb_0_0_0_0 = blocks.repack_bits_bb( 1, 8, 'len_key2', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, 1, 'len_key', False, gr.GR_MSB_FIRST) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(0.6) self.blocks_message_debug_0_0_0_0_0 = blocks.message_debug() self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/peter/Desktop/output.txt', False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_char_to_float_2 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_ff(2) self.band_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, samp_rate, freq_symbol_1 - 100, freq_symbol_1 + 100, 100, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, samp_rate, freq_symbol_0 - 100, freq_symbol_0 + 100, 100, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(44100, '', True) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq_symbol_1, 1, 0, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq_symbol_0, 1, 0, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0)) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'), (self.blocks_message_debug_0_0_0_0_0, 'print')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.audio_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_char_to_float_2, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_not_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_char_to_float_2, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_mux_1, 1)) self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_mux_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_1, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0_0_0_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Qpsk Usrp Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Usrp Loopback") 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", "qpsk_usrp_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.hdr_format = hdr_format ################################################## # Variables ################################################## self.qpsk = qpsk = digital.constellation_qpsk().base() self.excess_bw = excess_bw = 0.2 self.base_sps = base_sps = 5 self.sps = sps = 100 self.samp_rate = samp_rate = 0.4e6 self.rxmod = rxmod = digital.generic_mod(qpsk, False, base_sps, False, excess_bw, False, False) self.vec = vec = [ 0x96, 0x85, 0x81, 0x4a, 0xd7, 0x2e, 0x73, 0xe4, 0x33, 0x33, 0x47, 0xfc, 0x67, 0x3f, 0x72, 0x23, 0x44, 0x15, 0xc0, 0x04, 0x09, 0x13, 0x59, 0x77 ] self.rrc_taps_rx = rrc_taps_rx = firdes.root_raised_cosine( 32, samp_rate / base_sps, base_sps, excess_bw, 11 * base_sps * 3) self.nfilts = nfilts = 32 self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), ([0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc]), ([1])) self.carrier_freq = carrier_freq = 85e3 self.baseband_bw = baseband_bw = (1 + excess_bw) * (samp_rate / sps) self.acc_code = acc_code = "1111111100000000111100001111000011001100111111110000000010101010" ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), 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(uhd.tune_request(carrier_freq), 0) self.uhd_usrp_source_0.set_normalized_gain(0.5, 0) self.uhd_usrp_source_0.set_antenna('A', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), 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(carrier_freq), 0) self.uhd_usrp_sink_0.set_normalized_gain(0.5, 0) self.uhd_usrp_sink_0.set_antenna('A', 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "scope", #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(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, False) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_NORM, 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(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Correlation Estimate", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.4) self.qtgui_time_sink_x_1.set_y_axis(-1, 2000) 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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 5e-05, 0, 'corr_est') self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) 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_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "End", #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, 150) 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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "len_key2") 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) 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) 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("BER") 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) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "scope", #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(False) 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 512, #size "scope", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.05) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) 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(False) 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) self.math_0 = iio.iio_math('10^(-x)', 1) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1.2, samp_rate, 5e3, 1000, firdes.WIN_HAMMING, 6.76)) self.fir_filter_xxx_0 = filter.fir_filter_ccc(sps / base_sps, (100, )) self.fir_filter_xxx_0.declare_sample_delay(0) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( base_sps, 62.8e-3, (rrc_taps_rx), 36, 36 / 2, 1.25, 3) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 5, 5E-3, 3, qpsk) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 62.8e-3, 4, False) self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 2, "len_key2") self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), base_sps, 150, 0.91) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( qpsk) self.blocks_vector_source_x_0 = blocks.vector_source_b( vec, True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 119, "len_key") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, len(vec), "len_key") self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fec_ber_bf_0, 1)) self.connect((self.blocks_tag_gate_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tagged_stream_mux_0_0, 1)) self.connect((self.blocks_tagged_stream_mux_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_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), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.fec_ber_bf_0, 0), (self.math_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.math_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, freq=5000, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0), input_file="test_input.txt"): gr.top_block.__init__(self, "Qpsk Tx 0217") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Tx 0217") 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", "qpsk_tx_0217") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.hdr_format = hdr_format self.input_file = input_file ################################################## # Variables ################################################## self.sps = sps = 50 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 1 self.vec = vec = [ 0x96, 0x85, 0x81, 0x4a, 0xd7, 0x2e, 0x73, 0xe4, 0x33, 0x33, 0x47, 0xfc, 0x67, 0x3f, 0x72, 0x23, 0x44, 0x15, 0xc0, 0x04, 0x09, 0x13, 0x59, 0x77 ] self.samp_rate = samp_rate = 44100 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_qpsk().base() self.excess_bw_0 = excess_bw_0 = 1 self.carrier_freq = carrier_freq = freq ################################################## # Blocks ################################################## 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 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.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #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(-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(False) 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 "float" == "float" or "float" == "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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.7, verbose=False, log=False, ) self.blocks_wavfile_sink_0 = blocks.wavfile_sink( '/home/peter/Desktop/out.wav', 1, samp_rate, 8) self.blocks_vector_source_x_0 = blocks.vector_source_b( vec, True, 1, []) self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 119, "len_key") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, len(vec), "len_key") self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.6, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, carrier_freq, -1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tagged_stream_mux_0_0, 1)) self.connect((self.blocks_tagged_stream_mux_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") 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", "tx_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 100000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 478 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('serial= 31DDAA6', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(3000000) self.uhd_usrp_sink_0.set_center_freq(1E9, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #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(False) 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 = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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: 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_grid_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, #bw 'FFT Plot', #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(False) 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/csy/worktest/spectrum_sense/mydatafile/mydata_v2.log', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, hdr_const=digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base(), hdr_format=digital.header_format_default(digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Frame Synchronization") Qt.QWidget.__init__(self) self.setWindowTitle("Frame Synchronization") 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", "frame_synchronization") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.hdr_const = hdr_const self.hdr_format = hdr_format ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1_0.enable_autoscale(True) self.qtgui_time_sink_x_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_1_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*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_1_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_1_0_win) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, 'len_key') self.digital_correlate_access_code_xx_ts_1 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code, 0, 'len_key2') self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc((hdr_const.points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'len_key2') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, 'len_key', 0) self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(1, 8, 'len_key2', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, hdr_const.bits_per_symbol(), 'len_key', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'len_key') self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(numpy.array([ord(c) for c in "Hello world!"], numpy.uint8))), 500) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_tag_gate_0_0, 0), (self.digital_correlate_access_code_xx_ts_1, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.qtgui_time_sink_x_0_1_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1, 0), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0))
def __init__(self, doc, ip="127.0.0.1"): gr.top_block.__init__(self, "RL Mod training") self.doc = doc self.plot_lst = [] self.widget_lst = [] ################################################## # Parameters ################################################## self.ip = ip ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_length_tag_key = packet_length_tag_key = "packet_length" self.occupied_carriers = occupied_carriers = (list(range(-22, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 23)),) self.length_tag_key_0 = length_tag_key_0 = "frame_len" self.length_tag_key = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.bits_per_symbol = bits_per_symbol = 4 self.variable_0 = variable_0 = len(occupied_carriers[0]) self.tx_lr = tx_lr = -3 self.tx_explo = tx_explo = 0.15 self.training_mod = training_mod = 1 self.timestamp = timestamp = '1' self.t_state = t_state = 1 self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.] self.samp_rate = samp_rate = 0.3e6 self.rolloff = rolloff = 0 self.puncpat = puncpat = '11' self.payload_mod = payload_mod = digital.qam_constellation(constellation_points=2**bits_per_symbol) self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 400 self.ldpc_enc = ldpc_enc = fec.ldpc_encoder_make(gr.prefix() + "/share/gnuradio/fec/ldpc/" + "n_0100_k_0042_gap_02.alist") self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key_0, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=8, scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, length_tag_key,) self.gain = gain = 10 self.freq = freq = 900e6 self.bits_per_symbol_0 = bits_per_symbol_0 = len(occupied_carriers[0]) ################################################## # Blocks ################################################## self.tx_lr_slider = bokehgui.slider(self.widget_lst, 'TX Learning rate (log)' +":", -5, 0, 0.1, 1, -3) self.tx_lr_slider.add_callback(lambda attr, old, new: self.set_tx_lr(new)) self.tx_explo_slider = bokehgui.slider(self.widget_lst, 'TX Exploration noise' +":", 0.001, 0.5, 0.001, 1, 0.15) self.tx_explo_slider.add_callback(lambda attr, old, new: self.set_tx_explo(new)) self.training_mod_textbox = bokehgui.textbox(self.widget_lst, str(1), 'Alternate training every' +": ") self.training_mod_textbox.add_callback( lambda attr, old, new: self.set_training_mod(int(new))) self._t_state_options = [ 1, 0, ] self._t_state_labels = [ 'On', 'Off', ] self.t_state_radiobutton = bokehgui.radiobutton(self.widget_lst, None, self._t_state_labels, inline = True) self.t_state_radiobutton.add_callback( lambda new: self.set_t_state(int(self._t_state_options[new]))) self.gain_slider = bokehgui.slider(self.widget_lst, 'Amplitude' +":", 0, 90, 0.5, 1, 10) self.gain_slider.add_callback(lambda attr, old, new: self.set_gain(new)) self.zeromq_sub_msg_source_0_1 = zeromq.sub_msg_source("tcp://"+ip+":50002", 100) self.zeromq_pub_msg_sink_0_0 = zeromq.pub_msg_sink('tcp://*:50001', 100) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0,1)), ), length_tag_key, ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.timestamp_textbox = bokehgui.textbox(self.widget_lst, str('1'), 'Load timestamp' +": ") self.timestamp_textbox.add_callback( lambda attr, old, new: self.set_timestamp(str(new))) self.learning_tag_numerotation_0 = learning.tag_numerotation('packet_num', packet_len, 4096, "bb") self.learning_rl_mod_0 = learning.rl_mod('packet_num', bits_per_symbol, packet_len, 1, training_mod, 10**tx_lr , tx_explo, t_state , '/home/cyrille/Gnu-Radio/modules/gr-learning/examples/saved_models') self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.fec_extended_encoder_1_0_0 = fec.extended_encoder(encoder_obj_list=ldpc_enc, threading= None, puncpat=puncpat) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len//4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1) self.bokehgui_time_const_x_0 = bokehgui.time_sink_c_proc(1024, samp_rate, "Transmitted noiseless constellation", 1) self.bokehgui_time_const_x_0_plot = bokehgui.const_sink_c(self.doc, self.plot_lst, self.bokehgui_time_const_x_0, is_message = False) labels = ['', '', '', '', '', '', '', '', '', ''] legend_list = [] for i in range( 1 ): if len(labels[i]) == 0: if(i % 2 == 0): legend_list.append("Re{{Data {0}}}".format(i/2)) else: legend_list.append("Im{{Data {0}}}".format(i/2)) else: legend_list.append(labels[i]) self.bokehgui_time_const_x_0_plot.initialize(update_time = 500, legend_list = legend_list) self.bokehgui_time_const_x_0_plot.set_y_axis([-2, 2]) self.bokehgui_time_const_x_0_plot.set_y_label('Q Channel' + '(' +""+')') self.bokehgui_time_const_x_0_plot.set_x_label('I Channel' + '(' +""+')') self.bokehgui_time_const_x_0_plot.enable_tags(-1, False) self.bokehgui_time_const_x_0_plot.set_trigger_mode(bokehgui.TRIG_MODE_FREE, bokehgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.bokehgui_time_const_x_0_plot.enable_grid(False) self.bokehgui_time_const_x_0_plot.enable_axis_labels(True) self.bokehgui_time_const_x_0_plot.disable_legend(not True) self.bokehgui_time_const_x_0_plot.set_layout(*((0,1,2,2))) colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "blue", "blue", "blue"] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = ['o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range( 1 ): self.bokehgui_time_const_x_0_plot.format_line(i, colors[i], widths[i], 'None', markers[i], alphas[i]) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate/6,True) self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(1, bits_per_symbol, '', False, gr.GR_LSB_FIRST) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(0.01, 1) self.analog_random_source_x_0_0 = blocks.vector_source_b(list(map(int, numpy.random.randint(0, 2, 1000))), True) if self.widget_lst: input_t = bokehgui.bokeh_layout.widgetbox(self.widget_lst) widgetbox = bokehgui.bokeh_layout.WidgetLayout(input_t) widgetbox.set_layout(*((0, 0, 2, 1))) list_obj = [widgetbox] + self.plot_lst else: list_obj = self.plot_lst layout_t = bokehgui.bokeh_layout.create_layout(list_obj, "fixed") self.doc.add_root(layout_t) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'), (self.zeromq_pub_msg_sink_0_0, 'in')) self.msg_connect((self.zeromq_sub_msg_source_0_1, 'out'), (self.learning_rl_mod_0, 'losses')) self.connect((self.analog_random_source_x_0_0, 0), (self.fec_extended_encoder_1_0_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.learning_tag_numerotation_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) self.connect((self.fec_extended_encoder_1_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.learning_rl_mod_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.learning_rl_mod_0, 1), (self.bokehgui_time_const_x_0, 0)) self.connect((self.learning_tag_numerotation_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.learning_tag_numerotation_0, 0), (self.learning_rl_mod_0, 0))
def __init__(self, input_port_num="55555", output_port_num="55556", rx_bw=1e6, rx_freq=2.2e9, rx_gain=0.8, serial_num="31C9237", tx_bw=1e6, tx_freq=2.2e9, tx_gain=0.8): gr.top_block.__init__(self, "tranceiver_ofdm_usrp_RS") ################################################## # Parameters ################################################## self.input_port_num = input_port_num self.output_port_num = output_port_num self.rx_bw = rx_bw self.rx_freq = rx_freq self.rx_gain = rx_gain self.serial_num = serial_num self.tx_bw = tx_bw self.tx_freq = tx_freq self.tx_gain = tx_gain ################################################## # Variables ################################################## self.packet_len = packet_len = 200 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.n = n = 255 self.length_tag_key = length_tag_key = "frame_len" self.k = k = packet_len + 4 self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.blocks_RS = blocks_RS = 1 self.t = t = int((n * blocks_RS - k) / 2) self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 10000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.out_buf_size = out_buf_size = 0 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source( gr.sizeof_char, 1, "tcp://127.0.0.1:" + input_port_num, 100, False, -1) self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, "tcp://127.0.0.1:55556", 100, False, -1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_samp_rate(rx_bw) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), packet_length_tag_key, ) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_samp_rate(tx_bw) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 100, 1000) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, n, k, t, 0, blocks_RS) self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec( 2, 8, 0x11d, n, k, t, 0, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, packet_length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len // 4, rolloff, packet_length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key, True) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_crc32_bb_0_0 = digital.crc32_bb(False, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_char * 1, k) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_char * 1, n) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, packet_length_tag_key, k / n) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, packet_length_tag_key, n / k) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_char * 1, k) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, n) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, k, packet_length_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, packet_length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.dtv_dvbt_reed_solomon_dec_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Qpsk Test 0207") Qt.QWidget.__init__(self) self.setWindowTitle("Qpsk Test 0207") 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", "qpsk_test_0207") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Parameters ################################################## self.hdr_format = hdr_format ################################################## # Variables ################################################## self.sps = sps = 50 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 1 self.samp_rate = samp_rate = 44100 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts) self.qpsk = qpsk = digital.constellation_qpsk().base() self.lpf_transition_width = lpf_transition_width = 100 self.lpf_cutoff_freq = lpf_cutoff_freq = 3e3 self.carrier_freq = carrier_freq = 5e3 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Header+Payload", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-1, 1.5) self.qtgui_time_sink_x_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "len_key") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 1, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Raw Output Bits", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1.5) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "len_key") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 1, 1, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(1, 2)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #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(-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(False) 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.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.05) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) 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(False) 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, 0, 0, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 1)] self.low_pass_filter_0_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, lpf_cutoff_freq, lpf_transition_width, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, lpf_cutoff_freq, lpf_transition_width, firdes.WIN_HAMMING, 6.76)) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 62.8e-3, (rrc_taps), nfilts, nfilts / 2, 1.5, 8) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 20, 19E-3, 8, qpsk) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 62.8e-3, 4, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.7, verbose=False, log=False, ) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( qpsk) self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 3, 2, 1), True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 35, "len_key") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 48 * 10, "len_key") self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blks2_tcp_sink_0_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=9989, server=False, ) self.audio_source_0 = audio.source(44100, '', True) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_SIN_WAVE, carrier_freq, -1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.blks2_tcp_sink_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tagged_stream_mux_0_0, 1)) self.connect((self.blocks_tagged_stream_mux_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_float_to_complex_0, 1))
def __init__(self): gr.top_block.__init__(self, "OFDM_TX_RX_1") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM_TX_RX_1") 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", "OFDM_TX_RX_1") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.length_tag_key_rx = length_tag_key_rx = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 1000000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 30 self.length_tag_key = length_tag_key = "packet_len" self.header_len = header_len = 10 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key_rx, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=[], ), '', ) self.uhd_usrp_sink_0.set_center_freq(3.555e9, 0) self.uhd_usrp_sink_0.set_gain(31, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(0.5e6, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec()) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ), length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + 16, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/local/repository/gnuradio/file_to_transmit.txt', False, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, hdr_format=digital.header_format_default( digital.packet_utils.default_access_code, 0)): gr.top_block.__init__(self, "Audio modem FSK loop back test") Qt.QWidget.__init__(self) self.setWindowTitle("Audio modem FSK loop back test") 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.hdr_format = hdr_format ################################################## # Variables ################################################## self.nfilts = nfilts = 32 self.SPS = SPS = 147 self.RX_decimation = RX_decimation = 49 self.EBW = EBW = .05 self.samp_rate = samp_rate = 44.1E3 self.fsk_deviation_hz = fsk_deviation_hz = 100 self.carrier_freq = carrier_freq = 1.75E3 self.RRC_filter_taps = RRC_filter_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, EBW, 5 * SPS * nfilts / RX_decimation) ################################################## # Blocks ################################################## self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=1, decimation=RX_decimation, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate / RX_decimation, #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 / RX_decimation, #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(False) 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.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '', False, False, '') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win) self.epy_block_0 = epy_block_0.msg_block() self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, 'len_key') self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( SPS / RX_decimation, 6.28 / 400.0 * 2 / 70, (RRC_filter_taps), nfilts, nfilts / 2, 2, 1) self.digital_correlate_access_code_xx_ts_1_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 2, 'len_key2') self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bf( ((2 * 3.14 * carrier_freq - 2 * 3.14 * fsk_deviation_hz, 2 * 3.14 * carrier_freq + 2 * 3.14 * fsk_deviation_hz)), 1) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0), True, 1, []) self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 1, 1) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'len_key2') self.blocks_tagged_stream_mux_1 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_char * 1, 'len_key', 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 200, 'len_key') self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float * 1, SPS - 1) self.blocks_repack_bits_bb_0_0_0_0 = blocks.repack_bits_bb( 1, 8, 'len_key2', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, 1, 'len_key', False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'len_key') self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.audio_source_0 = audio.source(44100, '', True) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -carrier_freq, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_deviation_hz / 8.0) / (RX_decimation)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-60, .01, 0, True) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1.0) self.analog_const_source_x_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.blocks_message_debug_0_0, 'print')) self.msg_connect((self.epy_block_0, 'msg_out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.epy_block_0, 'msg_in')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_feedforward_agc_cc_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_tagged_stream_mux_1, 1)) self.connect((self.blocks_repack_bits_bb_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_1, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_1, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_correlate_access_code_xx_ts_1_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1_0_0, 0), (self.blocks_repack_bits_bb_0_0_0_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.analog_pwr_squelch_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Frame Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Frame Sync") 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", "frame_sync") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.length_tag_key = length_tag_key = "# of bits" self.header_mod = header_mod = digital.constellation_bpsk() ################################################## # Blocks ################################################## self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key) self.digital_crc32_bb_0_0 = digital.crc32_bb(True, length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_correlate_access_code_xx_ts_1 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code, 1, length_tag_key) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1) self.digital_chunks_to_symbols_xx_0_0_0_0_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, length_tag_key) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0_0.set_single_key("") self.blocks_repack_bits_bb_0_0_1_0 = blocks.repack_bits_bb(8, header_mod.bits_per_symbol(), length_tag_key, False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0_1 = blocks.repack_bits_bb(8, header_mod.bits_per_symbol(), length_tag_key, False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(1, 8, length_tag_key, False, gr.GR_MSB_FIRST) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, length_tag_key) self.blocks_message_strobe_0_0_0_0 = blocks.message_strobe(pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(numpy.array([ord(c) for c in "Beyond 5G"], numpy.uint8))), 1000) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.7, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0_0_0, 'strobe'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_1, 0), (self.digital_chunks_to_symbols_xx_0_0_0_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0, 0)) self.connect((self.blocks_tag_gate_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_correlate_access_code_xx_ts_1, 0)) self.connect((self.digital_correlate_access_code_xx_ts_1, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0_0_1, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "DL Demod training") Qt.QWidget.__init__(self) self.setWindowTitle("DL Demod training") 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", "ofdm_base") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_length" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.length_tag_key_0 = length_tag_key_0 = "frame_len" self.length_tag_key = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.errors = errors = 0 self.variable_qtgui_label_0 = variable_qtgui_label_0 = errors self.training_mod = training_mod = 10 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.stop_button = stop_button = 0 self.stop_button_args = stop_button_args = None self.start_button = start_button = 0 self.start_button_args = start_button_args = None self.snr_stop = snr_stop = 12 self.snr_step = snr_step = 0.2 self.snr_start = snr_start = -4 self.samp_rate = samp_rate = 1e6 self.rolloff = rolloff = 0 self.reset_ber = reset_ber = 0 self.reset_ber_args = reset_ber_args = None self.reset = reset = 0 self.reset_args = reset_args = None self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 256 self.mag = mag = -4 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key_0, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.gain_rx = gain_rx = 0 self.gain = gain = 30 self.freq = freq = 900e6 ################################################## # Blocks ################################################## self._training_mod_tool_bar = Qt.QToolBar(self) self._training_mod_tool_bar.addWidget( Qt.QLabel('Alternate training every' + ": ")) self._training_mod_line_edit = Qt.QLineEdit(str(self.training_mod)) self._training_mod_tool_bar.addWidget(self._training_mod_line_edit) self._training_mod_line_edit.returnPressed.connect( lambda: self.set_training_mod( int(str(self._training_mod_line_edit.text())))) self.top_grid_layout.addWidget(self._training_mod_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._mag_range = Range(snr_start, 20, 0.01, -4, 200) self._mag_win = RangeWidget(self._mag_range, self.set_mag, 'Magnitude', "counter_slider", float) self.top_grid_layout.addWidget(self._mag_win, 2, 0, 2, 2) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.learning_sweeper_0 = learning.sweeper( self, np.arange(snr_start, snr_stop, snr_step), 200, 'learning_ber_bf_0', 'blocks_probe_signal_x_0', self.set_mag) self.learning_dl_demod_0 = learning.dl_demod('packet_num', packet_len * 4, 16, training_mod, 0.05) self.learning_ber_bf_0 = learning.ber_bf(False, 100, -7.0, 2) self._gain_rx_range = Range(0, 90, .2, 0, 200) self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx, 'Amplitude Rx', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rx_win, 0, 2, 2, 1) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._gain_range = Range(0, 90, .2, 30, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win, 0, 0, 2, 2) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) 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: str(x) self._variable_qtgui_label_0_tool_bar.addWidget( Qt.QLabel('Error count' + ": ")) 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_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 4, 1, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=[], ), ) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_rx_agc(False, 0) self.uhd_usrp_source_0.set_gain(gain_rx, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=[], ), '', ) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) _stop_button_push_button = Qt.QPushButton('&Stop sweep') def stop_button_handler(): if self.stop_button_args is not None: self.set_stop_button(self.learning_sweeper_0.stop_sweep()) else: self.set_stop_button(self.learning_sweeper_0.stop_sweep()) _stop_button_push_button.clicked.connect(stop_button_handler) self.top_grid_layout.addWidget(_stop_button_push_button, 9, 0, 1, 1) for r in range(9, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _start_button_push_button = Qt.QPushButton('&Start sweep') def start_button_handler(): if self.start_button_args is not None: self.set_start_button(self.learning_sweeper_0.start_sweep()) else: self.set_start_button(self.learning_sweeper_0.start_sweep()) _start_button_push_button.clicked.connect(start_button_handler) self.top_grid_layout.addWidget(_start_button_push_button, 8, 0, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) _reset_ber_push_button = Qt.QPushButton( "Reset &BER last: {}".format(reset_ber)) def reset_ber_handler(): if self.reset_ber_args is not None: self.set_reset_ber(self.learning_ber_bf_0.reset_counters()) else: self.set_reset_ber(self.learning_ber_bf_0.reset_counters()) _reset_ber_push_button.clicked.connect(reset_ber_handler) self.top_grid_layout.addWidget(_reset_ber_push_button, 5, 1, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) _reset_push_button = Qt.QPushButton('&Reset model state') def reset_handler(): if self.reset_args is not None: self.set_reset(self.learning_dl_demod_0.reset()) else: self.set_reset(self.learning_dl_demod_0.reset()) _reset_push_button.clicked.connect(reset_handler) self.top_grid_layout.addWidget(_reset_push_button, 5, 0, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_vector_sink_f_0 = qtgui.vector_sink_f( len(np.arange(snr_start, snr_stop, snr_step)), snr_start, snr_step, "Eb/N0", "BER (log)", "BER Curve", 2 # Number of inputs ) self.qtgui_vector_sink_f_0.set_update_time(0.10) self.qtgui_vector_sink_f_0.set_y_axis(-7, 0) self.qtgui_vector_sink_f_0.enable_autoscale(False) self.qtgui_vector_sink_f_0.enable_grid(False) self.qtgui_vector_sink_f_0.set_x_axis_units("") self.qtgui_vector_sink_f_0.set_y_axis_units("") self.qtgui_vector_sink_f_0.set_ref_level(0) labels = ['Measure', 'Theory', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): if len(labels[i]) == 0: self.qtgui_vector_sink_f_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_vector_sink_f_0.set_line_label(i, labels[i]) self.qtgui_vector_sink_f_0.set_line_width(i, widths[i]) self.qtgui_vector_sink_f_0.set_line_color(i, colors[i]) self.qtgui_vector_sink_f_0.set_line_alpha(i, alphas[i]) self._qtgui_vector_sink_f_0_win = sip.wrapinstance( self.qtgui_vector_sink_f_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_vector_sink_f_0_win, 8, 1, 2, 1) for r in range(8, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_num") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 6, 1, 2, 2) for r in range(6, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_1_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_1_0.set_update_time(0.10) self.qtgui_number_sink_1_0.set_title("BER") 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 range(1): self.qtgui_number_sink_1_0.set_min(i, 0) self.qtgui_number_sink_1_0.set_max(i, 100) self.qtgui_number_sink_1_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1_0.set_label(i, labels[i]) self.qtgui_number_sink_1_0.set_unit(i, units[i]) self.qtgui_number_sink_1_0.set_factor(i, factor[i]) self.qtgui_number_sink_1_0.enable_autoscale(False) self._qtgui_number_sink_1_0_win = sip.wrapinstance( self.qtgui_number_sink_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_1_0_win, 4, 2, 2, 1) for r in range(4, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0.8, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("Eb/No") 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 range(1): self.qtgui_number_sink_1.set_min(i, 0) self.qtgui_number_sink_1.set_max(i, 100) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_1_win, 2, 2, 2, 1) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) 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(-2, 2) 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(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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 range(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, 6, 0, 2, 1) for r in range(6, 8): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.learning_tag_numerotation_0 = learning.tag_numerotation( 'packet_num', packet_len * 4, 4096, "bb") self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1) def _errors_probe(): while True: val = self.learning_ber_bf_0.total_errors() try: self.set_errors(val) except AttributeError: pass time.sleep(1.0 / (10)) _errors_thread = threading.Thread(target=_errors_probe) _errors_thread.daemon = True _errors_thread.start() self.epy_block_0 = epy_block_0.alignement(tag_name="packet_num", frame_size=packet_len * 4) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.95) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key_0, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key_0, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key_0, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key_0, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len // 4, rolloff, length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key_0, "", True, gr.sizeof_gr_complex, "rx_time", int(samp_rate), (), 0) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_sub_xx_0_0 = blocks.sub_cc(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_probe_signal_x_0 = blocks.probe_signal_f() self.blocks_nlog10_ff_0 = blocks.nlog10_ff(-10, 1, 10 * np.log10(4 / 2)) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(0.05, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 5000, 1.0 / 5000, 4000, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 255, 1000))), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, np.sqrt(10**(np.log10(2) - (mag / 10.0))) * 1, -1) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.epy_block_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.learning_tag_numerotation_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_sub_xx_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0_0_0, 0), (self.blocks_sub_xx_0_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_0, 0)) self.connect((self.epy_block_0, 0), (self.blocks_sub_xx_0_0, 0)) self.connect((self.epy_block_0, 1), (self.digital_chunks_to_symbols_xx_0_0_0, 0)) self.connect((self.epy_block_0, 0), (self.learning_dl_demod_0, 0)) self.connect((self.epy_block_0, 1), (self.learning_dl_demod_0, 1)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.learning_ber_bf_0, 0), (self.blocks_probe_signal_x_0, 0)) self.connect((self.learning_ber_bf_0, 0), (self.qtgui_number_sink_1_0, 0)) self.connect((self.learning_dl_demod_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.learning_dl_demod_0, 1), (self.blocks_char_to_float_0_0_0, 0)) self.connect((self.learning_dl_demod_0, 0), (self.learning_ber_bf_0, 0)) self.connect((self.learning_dl_demod_0, 1), (self.learning_ber_bf_0, 1)) self.connect((self.learning_sweeper_0, 0), (self.qtgui_vector_sink_f_0, 0)) self.connect((self.learning_sweeper_0, 1), (self.qtgui_vector_sink_f_0, 1)) self.connect((self.learning_tag_numerotation_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.learning_tag_numerotation_0, 0), (self.epy_block_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))