def __init__(self, beta_rrc=0.13, bits_per_symb=2, cfar_thresh=8, cfo_samps=512, corr_reps=2, log_interval=1, packet_len=512, samps_per_symb=2, spy_length=64, spy_thresh=0.1): gr.top_block.__init__(self, "Echo Classic Usrp Spy") ################################################## # Parameters ################################################## self.beta_rrc = beta_rrc self.bits_per_symb = bits_per_symb self.cfar_thresh = cfar_thresh self.cfo_samps = cfo_samps self.corr_reps = corr_reps self.log_interval = log_interval self.packet_len = packet_len self.samps_per_symb = samps_per_symb self.spy_length = spy_length self.spy_thresh = spy_thresh ################################################## # Variables ################################################## self.tx_gain = tx_gain = 4 self.samp_rate = samp_rate = 500000 self.rx_gain = rx_gain = 3 self.cfo_freqs = cfo_freqs = 11. / 256, 43. / 256, 97. / 256 self.body = body = [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ] self.F_center = F_center = 1000000000 ################################################## # Blocks ################################################## self.zeromq_pull_msg_source_tx = zeromq.pull_msg_source( "tcp://127.0.0.1:5555", 100, True) self.zeromq_pull_msg_source_rx = zeromq.pull_msg_source( "tcp://127.0.0.1:5556", 100, True) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(F_center, 0) self.uhd_usrp_source_0.set_gain(20, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq(F_center, 1) self.uhd_usrp_source_0.set_gain(rx_gain, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(F_center, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.echo_watchdog_0 = echo.watchdog(5) self.echo_preamble_insert_0_1 = echo.preamble_insert((body), 1, 0, 0) self.echo_preamble_insert_0_0 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_packet_length_check_0 = echo.packet_length_check( (2 * packet_len + spy_length) / bits_per_symb) self.echo_modulator_classic_spy_0 = echo.modulator_classic_spy( bits_per_symb, (body), log_interval, spy_length) self.echo_demodulator_classic_spy_0 = echo.demodulator_classic_spy( bits_per_symbol=bits_per_symb, block_length=1024, preamble=(body), log_ber_interval=log_interval, spy_length=spy_length, spy_threshold=spy_thresh) self.neural_to_classic_handler = echo.packet_handler( cfo_samps, corr_reps, (2 * packet_len + spy_length) / bits_per_symb, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.blocks_random_pdu_0 = blocks.random_pdu(packet_len, packet_len, chr(0x01), 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.echo_preamble_insert_0_1, 'in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_packet_length_check_0, 'in')) self.msg_connect((self.echo_demodulator_classic_spy_0, 'corrupt'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.echo_demodulator_classic_spy_0, 'bits'), (self.echo_preamble_insert_0, 'in')) self.msg_connect((self.echo_demodulator_classic_spy_0, 'bits'), (self.echo_preamble_insert_0_0, 'in')) self.msg_connect((self.echo_modulator_classic_spy_0, 'symbols'), (self.neural_to_classic_handler, 'wrap_in')) self.msg_connect((self.echo_packet_length_check_0, 'failed'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.echo_packet_length_check_0, 'validated'), (self.echo_demodulator_classic_spy_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0, 'passthrough'), (self.echo_watchdog_0, 'in')) self.msg_connect((self.echo_preamble_insert_0, 'out'), (self.echo_modulator_classic_spy_0, 'bits')) self.msg_connect((self.echo_preamble_insert_0_0, 'out'), (self.echo_modulator_classic_spy_0, 'update')) self.msg_connect((self.echo_preamble_insert_0_1, 'out'), (self.echo_modulator_classic_spy_0, 'bits')) self.msg_connect((self.echo_watchdog_0, 'out'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.zeromq_pull_msg_source_rx, 'out'), (self.uhd_usrp_source_0, 'command')) self.msg_connect((self.zeromq_pull_msg_source_tx, 'out'), (self.uhd_usrp_sink_0, 'command')) self.connect((self.neural_to_classic_handler, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.neural_to_classic_handler, 0))
def __init__(self, beta_rrc=0.13, bits_per_symb=2, cfar_thresh=8, cfo_samps=512, corr_reps=1, log_interval=10, packet_len=512, samps_per_symb=2): gr.top_block.__init__(self, "Echo Wrapper Neural") Qt.QWidget.__init__(self) self.setWindowTitle("Echo Wrapper Neural") 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", "echo_wrapper_neural") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.beta_rrc = beta_rrc self.bits_per_symb = bits_per_symb self.cfar_thresh = cfar_thresh self.cfo_samps = cfo_samps self.corr_reps = corr_reps self.log_interval = log_interval self.packet_len = packet_len self.samps_per_symb = samps_per_symb ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.cfo_freqs = cfo_freqs = 11. / 256, 43. / 256, 97. / 256 self.body = body = [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ] self.N0 = N0 = 0.1 ################################################## # Blocks ################################################## self.echo_triggered_vector_source_b_0 = echo.triggered_vector_source_b( (body * 2), "", 1, "pkt") self.echo_preamble_insert_1_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_preamble_insert_1 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0_0 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_packet_length_check_0_0 = echo.packet_length_check( packet_len / bits_per_symb * 2) self.echo_packet_length_check_0 = echo.packet_length_check( packet_len / bits_per_symb * 2) self.echo_modulator_neural_0 = echo.modulator_neural( 12348907843, (50, ), bits_per_symb, (body), log_interval, "") self.echo_modulator_classic_0 = echo.modulator_classic( bits_per_symb, (body), log_interval) self.echo_demodulator_neural_0 = echo.demodulator_neural( 134214, (50, ), bits_per_symb, (body), log_interval, "") self.echo_demodulator_classic_0 = echo.demodulator_classic( bits_per_symb, 1024, preamble=(body), log_ber_interval=log_interval) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 2048, #size "Channel IQ Scatter", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( packet_len / bits_per_symb * 2, #size "Detected Body Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.neural_to_classic_handler = echo.packet_handler( cfo_samps, corr_reps, packet_len / samps_per_symb * 2, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.classic_to_neural_handler = echo.packet_handler( cfo_samps, corr_reps, 2 * packet_len / samps_per_symb, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=N0, frequency_offset=0.000, epsilon=1, taps=(0.714 + 0.714j, ), noise_seed=0, block_tags=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=N0, frequency_offset=0.0000, epsilon=1, taps=(0.714 + 0.714j, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "pkt") self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex * 1, (1152 * 2, 5000)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex * 1, (1152 * 2, 5000)) self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, "pkt") self.analog_const_source_x_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.echo_modulator_neural_0, 'bits')) self.msg_connect((self.classic_to_neural_handler, 'unwrap_out'), (self.echo_packet_length_check_0, 'in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_packet_length_check_0_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0, 'bits'), (self.echo_preamble_insert_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0, 'bits'), (self.echo_preamble_insert_0_0, 'in')) self.msg_connect((self.echo_demodulator_neural_0, 'bits'), (self.echo_preamble_insert_1, 'in')) self.msg_connect((self.echo_demodulator_neural_0, 'bits'), (self.echo_preamble_insert_1_0, 'in')) self.msg_connect((self.echo_modulator_classic_0, 'symbols'), (self.classic_to_neural_handler, 'wrap_in')) self.msg_connect((self.echo_modulator_neural_0, 'symbols'), (self.neural_to_classic_handler, 'wrap_in')) self.msg_connect((self.echo_packet_length_check_0, 'validated'), (self.echo_demodulator_neural_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0, 'failed'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.echo_packet_length_check_0_0, 'validated'), (self.echo_demodulator_classic_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0_0, 'failed'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.echo_preamble_insert_0, 'out'), (self.echo_modulator_classic_0, 'bits')) self.msg_connect((self.echo_preamble_insert_0_0, 'out'), (self.echo_modulator_classic_0, 'update')) self.msg_connect((self.echo_preamble_insert_1, 'out'), (self.echo_modulator_neural_0, 'feedback')) self.msg_connect((self.echo_preamble_insert_1_0, 'out'), (self.echo_modulator_neural_0, 'bits')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_stream_mux_1, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.neural_to_classic_handler, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.classic_to_neural_handler, 0)) self.connect((self.classic_to_neural_handler, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.neural_to_classic_handler, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.echo_triggered_vector_source_b_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0))
def __init__(self, beta_rrc=0.13, bits_per_symb=2, cfar_thresh=10, cfo_samps=512, corr_reps=1, log_interval=10, packet_len=512, samps_per_symb=2): gr.top_block.__init__(self, "Echo Wrapper Classic Usrp") Qt.QWidget.__init__(self) self.setWindowTitle("Echo Wrapper Classic Usrp") 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", "echo_wrapper_classic_usrp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.beta_rrc = beta_rrc self.bits_per_symb = bits_per_symb self.cfar_thresh = cfar_thresh self.cfo_samps = cfo_samps self.corr_reps = corr_reps self.log_interval = log_interval self.packet_len = packet_len self.samps_per_symb = samps_per_symb ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500000 self.cfo_freqs = cfo_freqs = 11. / 256, 43. / 256, 97. / 256 self.body = body = [ 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0 ] self.F_center = F_center = 1000000000 ################################################## # Blocks ################################################## self.zeromq_pull_msg_source_tx = zeromq.pull_msg_source( "tcp://127.0.0.1:5555", 100, False) self.zeromq_pull_msg_source_rx = zeromq.pull_msg_source( "tcp://127.0.0.1:5556", 100, False) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(F_center, 0) self.uhd_usrp_source_0.set_gain(20, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_center_freq(F_center, 1) self.uhd_usrp_source_0.set_gain(5, 1) self.uhd_usrp_source_0.set_antenna("RX2", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(F_center, 0) self.uhd_usrp_sink_0.set_gain(5, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.echo_watchdog_0 = echo.watchdog(5) self.echo_triggered_vector_source_b_0 = echo.triggered_vector_source_b( (body), "", 1, "pkt") self.echo_preamble_insert_0_1 = echo.preamble_insert((body), 1, 0, 0) self.echo_preamble_insert_0_0 = echo.preamble_insert((body), 0, 1, 0) self.echo_preamble_insert_0 = echo.preamble_insert((body), 1, 0, 1) self.echo_packet_length_check_0 = echo.packet_length_check( packet_len / bits_per_symb * 2) self.echo_modulator_classic_1 = echo.modulator_classic( bits_per_symb, (body), log_interval) self.echo_demodulator_classic_0_0 = echo.demodulator_classic( bits_per_symb, 1024, preamble=(body), log_ber_interval=log_interval) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 2048, #size "Channel IQ Scatter", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(True) self.qtgui_const_sink_x_0_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0_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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( packet_len / bits_per_symb, #size "Detected Body Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.0) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.neural_to_classic_handler = echo.packet_handler( cfo_samps, corr_reps, packet_len / bits_per_symb * 2, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "pkt") self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, "pkt") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.echo_preamble_insert_0_1, 'in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_packet_length_check_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0_0, 'bits'), (self.echo_preamble_insert_0, 'in')) self.msg_connect((self.echo_demodulator_classic_0_0, 'bits'), (self.echo_preamble_insert_0_0, 'in')) self.msg_connect((self.echo_modulator_classic_1, 'symbols'), (self.neural_to_classic_handler, 'wrap_in')) self.msg_connect((self.echo_packet_length_check_0, 'validated'), (self.echo_demodulator_classic_0_0, 'symbols')) self.msg_connect((self.echo_packet_length_check_0, 'failed'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.echo_packet_length_check_0, 'passthrough'), (self.echo_watchdog_0, 'in')) self.msg_connect((self.echo_preamble_insert_0, 'out'), (self.echo_modulator_classic_1, 'bits')) self.msg_connect((self.echo_preamble_insert_0_0, 'out'), (self.echo_modulator_classic_1, 'update')) self.msg_connect((self.echo_preamble_insert_0_1, 'out'), (self.echo_modulator_classic_1, 'bits')) self.msg_connect((self.echo_watchdog_0, 'out'), (self.echo_triggered_vector_source_b_0, 'trigger')) self.msg_connect((self.zeromq_pull_msg_source_rx, 'out'), (self.uhd_usrp_source_0, 'command')) self.msg_connect((self.zeromq_pull_msg_source_tx, 'out'), (self.uhd_usrp_sink_0, 'command')) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.neural_to_classic_handler, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.echo_triggered_vector_source_b_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.neural_to_classic_handler, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.qtgui_const_sink_x_0_0_0, 0))