def __init__(self, ipp1="127.0.0.1", ipp2="127.0.0.1", ipp3="127.0.0.1", ipp4="127.0.0.1", iptx="127.0.0.1", samp_rate=10000): gr.top_block.__init__(self, "OFDM Rx") ################################################## # Parameters ################################################## self.ipp1 = ipp1 self.ipp2 = ipp2 self.ipp3 = ipp3 self.ipp4 = ipp4 self.iptx = iptx self.samp_rate = samp_rate ################################################## # 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 = "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.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) ################################################## # Blocks ################################################## self.zeromq_push_sink_0_0_1_0 = zeromq.push_sink(gr.sizeof_gr_complex, 64, "tcp://"+ ipp2 + ":55521", 100, True) self.zeromq_push_sink_0_0_1 = zeromq.push_sink(gr.sizeof_gr_complex, 64, "tcp://"+ ipp2 + ":55520", 100, True) self.zeromq_pull_source_0_0_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://"+ ipp1 + ":55511", 100, True) self.zeromq_pull_source_0_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://"+ ipp1 + ":55510", 100, True) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source("tcp://"+ ipp3 + ":55530", 100) 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, (), ) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.digital_header_payload_demux_0, 0), (self.zeromq_push_sink_0_0_1, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.zeromq_push_sink_0_0_1_0, 0)) self.connect((self.zeromq_pull_source_0_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.zeromq_pull_source_0_0_0, 0), (self.digital_header_payload_demux_0, 1))
def setUp(self): addr = 'tcp://127.0.0.1' self.context = zmq.Context() self.zmq_sock = self.context.socket(zmq.PUSH) port = self.zmq_sock.bind_to_random_port(addr) self.zeromq_pull_msg_source = zeromq.pull_msg_source( ('%s:%s' % (addr, port)), 100) self.message_debug = blocks.message_debug() self.tb = gr.top_block() self.tb.msg_connect((self.zeromq_pull_msg_source, 'out'), (self.message_debug, 'store')) self.tb.start() time.sleep(0.1)
def __init__(self, rf_params, tcp_addr): gr.hier_block2.__init__( self, "TX Source Block", gr.io_signature(0, 0, 0), # no inputs gr.io_signature(1, 1, gr.sizeof_char * 1) # single out ) # parameters self.rf_params = rf_params self.tcp_addr = tcp_addr # instantiate the zmq source self.bb_src = zeromq.pull_msg_source(self.tcp_addr, 100) # convert the message PDU to a stream with tags self.pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, 'len_key') self.msg_connect((self.bb_src, 'out'), (self.pdu_to_ts, 'pdus')) self.connect((self.pdu_to_ts, 0), (self, 0))
def __init__(self): gr.top_block.__init__(self, "RTTY_vco", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("RTTY_vco") 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", "RTTY_vco") 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.vco_max = vco_max = 2500 self.fsk_deviation = fsk_deviation = 170 self.center = center = 2210 self.vco_offset = vco_offset = (center - (fsk_deviation / 2)) / vco_max self.samp_rate = samp_rate = 48000 self.repeat = repeat = (int)(samp_rate * 0.022) self.inp_amp = inp_amp = ((center + (fsk_deviation / 2)) / vco_max) - vco_offset self.baud = baud = 1 / 0.022 ################################################## # Blocks ################################################## self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source( 'tcp://127.0.0.1:50251', 100, False) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 2, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1.5) 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_NORM, qtgui.TRIG_SLOPE_NEG, 0.5, 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(True) 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(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_fff( 1, firdes.low_pass(1, samp_rate, 200, 1000, firdes.WIN_HAMMING, 6.76)) self.epy_block_0_0 = epy_block_0_0.mc_sync_block() self.blocks_vco_f_0 = blocks.vco_f(samp_rate, 15708, 0.5) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, repeat) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(inp_amp) self.blocks_add_const_vxx_0 = blocks.add_const_ff(vco_offset) self.audio_sink_0 = audio.sink(48000, '', True) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.epy_block_0_0, 'msg_in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_vco_f_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_vco_f_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.epy_block_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_time_sink_x_0, 0))
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): gr.top_block.__init__(self, "Morse Code Generator", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Morse Code Generator") 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", "MorseGen_xmt") 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.speed = speed = 13 self.samp_rate = samp_rate = 50000 self.usrp_rate = usrp_rate = 1000000 self.symbol_rate = symbol_rate = 300 self.rf_gain = rf_gain = 9 self.repeat = repeat = int(1.2 * samp_rate / speed) self.center_freq = center_freq = 144.95e6 ################################################## # Blocks ################################################## self._rf_gain_range = Range(0, 76, 1, 9, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, 'RF Gain', "counter_slider", int, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._rf_gain_win) self._center_freq_range = Range(144.0e6, 148.0e6, 1.0e3, 144.95e6, 200) self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, 'Tuning', "counter_slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._center_freq_win) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source( 'tcp://127.0.0.1:50251', 100, False) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), '', ) self.uhd_usrp_sink_0.set_samp_rate(usrp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec(0)) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(200000, 0) self.uhd_usrp_sink_0.set_gain(rf_gain, 0) self.root_raised_cosine_filter_0_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(0.95, samp_rate, symbol_rate, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, samp_rate, symbol_rate, 0.35, 200)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 16384, #size samp_rate, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1.5) 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_AUTO, qtgui.TRIG_SLOPE_POS, 0.5, 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(True) 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.epy_block_0_0 = epy_block_0_0.mc_sync_block() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * 1, (int)(usrp_rate / samp_rate)) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, repeat) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.epy_block_0_0, 'msg_in')) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.epy_block_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self, beta_rrc=0.13, bits_per_symb=2, cfar_thresh=50, cfo_samps=512, corr_reps=2, demod_hidden_layers=[50], demod_init_weights="", demod_seed=341133, demodtype="neural", lambda_center=1, log_interval=1, max_amplitude=0.707, mod_hidden_layers=[50], mod_init_weights="", mod_seed=341132, modtype="neural", packet_len=256, rx_gain=4, samps_per_symb=2, shared_preamble="", spy_thresh=0.1, tx_gain=3): gr.top_block.__init__(self, "Echo Single-USRP Flowgraph") ################################################## # 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.demod_hidden_layers = demod_hidden_layers self.demod_init_weights = demod_init_weights self.demod_seed = demod_seed self.demodtype = demodtype self.lambda_center = lambda_center self.log_interval = log_interval self.max_amplitude = max_amplitude self.mod_hidden_layers = mod_hidden_layers self.mod_init_weights = mod_init_weights self.mod_seed = mod_seed self.modtype = modtype self.packet_len = packet_len self.rx_gain = rx_gain self.samps_per_symb = samps_per_symb self.shared_preamble = shared_preamble self.spy_thresh = spy_thresh self.tx_gain = tx_gain ################################################## # Variables ################################################## self.spy_length = spy_length = 64 * bits_per_symb self.samp_rate = samp_rate = 500000 self.full_len = full_len = 2 * packet_len + (spy_length + 96) / bits_per_symb self.cfo_freqs = cfo_freqs = 11./256, 43./256, 97./256 self.F_center = F_center = 1000000000 ################################################## # Blocks ################################################## self.zeromq_pull_msg_source_1 = zeromq.pull_msg_source("tcp://127.0.0.1:5556", 100, True) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source("tcp://127.0.0.1:5555", 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(rx_gain, 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(1) self.echo_echo_mod_demod_0 = echo.echo_mod_demod(packet_len * bits_per_symb, shared_preamble, bits_per_symb, modtype, demodtype, mod_seed=mod_seed, demod_seed=demod_seed, mod_hidden_layers=(mod_hidden_layers), demod_hidden_layers=(demod_hidden_layers), mod_init_weights=mod_init_weights, demod_init_weights=demod_init_weights, log_interval=log_interval, spy_length=spy_length, spy_threshold=0.1, max_amplitude=max_amplitude, lambda_center=lambda_center, _alias="neural-agent") self.neural_to_classic_handler = echo.packet_handler(cfo_samps, corr_reps, full_len, cfar_thresh, samps_per_symb, beta_rrc, (cfo_freqs)) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0000, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 0.0j, ), noise_seed=0, block_tags=False ) self.blocks_random_pdu_0 = blocks.random_pdu(2 * packet_len * bits_per_symb, 2 * packet_len * bits_per_symb, chr(0x01), 2) 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_echo_mod_demod_0, 'mod_in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_echo_mod_demod_0, 'demod_in')) self.msg_connect((self.neural_to_classic_handler, 'unwrap_out'), (self.echo_watchdog_0, 'in')) self.msg_connect((self.echo_echo_mod_demod_0, 'mod_out'), (self.neural_to_classic_handler, 'wrap_in')) self.msg_connect((self.echo_watchdog_0, 'out'), (self.blocks_random_pdu_0, 'generate')) self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.echo_echo_mod_demod_0, 'control')) self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.uhd_usrp_sink_0, 'command')) self.msg_connect((self.zeromq_pull_msg_source_1, 'out'), (self.echo_echo_mod_demod_0, 'control')) self.msg_connect((self.zeromq_pull_msg_source_1, 'out'), (self.uhd_usrp_source_0, 'command')) self.connect((self.channels_channel_model_0, 0), (self.neural_to_classic_handler, 0)) 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.channels_channel_model_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))
def __init__(self): gr.top_block.__init__(self, "Morse Code Generator", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("Morse Code Generator") 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", "MorseGen_alt") 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.speed = speed = 13 self.samp_rate = samp_rate = 48000 self.volume = volume = 0.05 self.symbol_rate = symbol_rate = 300 self.repeat = repeat = int(1.2 * samp_rate / speed) self.freq = freq = 800 ################################################## # Blocks ################################################## self._volume_range = Range(0, 1.0, 0.01, 0.05, 200) self._volume_win = RangeWidget(self._volume_range, self.set_volume, 'Volume', "slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._volume_win) self._freq_range = Range(300, 2000, 100, 800, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'freq', "counter_slider", float, QtCore.Qt.Horizontal) self.top_grid_layout.addWidget(self._freq_win) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source( 'tcp://127.0.0.1:50251', 100, False) self.root_raised_cosine_filter_0_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, samp_rate, symbol_rate, 0.35, 200)) self.root_raised_cosine_filter_0 = filter.fir_filter_fff( 1, firdes.root_raised_cosine(1, samp_rate, symbol_rate, 0.35, 200)) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 16384, #size samp_rate, #samp_rate "", #name 2, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1.5) 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_AUTO, qtgui.TRIG_SLOPE_POS, 0.5, 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(True) 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(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.epy_block_0_0 = epy_block_0_0.mc_sync_block() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, repeat) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_ff(volume) self.audio_sink_0 = audio.sink(48000, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, freq, 0.5, 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.epy_block_0_0, 'msg_in')) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.epy_block_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "RTTY_xmt", catch_exceptions=True) Qt.QWidget.__init__(self) self.setWindowTitle("RTTY_xmt") 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", "RTTY_xmt") 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.vco_max = vco_max = 2500 self.fsk_deviation = fsk_deviation = 170 self.center = center = 2210 self.vco_offset = vco_offset = (center - (fsk_deviation / 2)) / vco_max self.usrp_rate = usrp_rate = 768000 self.samp_rate = samp_rate = 48000 self.rf_gain = rf_gain = 9 self.rf_decim = rf_decim = 100 self.repeat = repeat = (int)(samp_rate * 0.022) self.inp_amp = inp_amp = ((center + (fsk_deviation / 2)) / vco_max) - vco_offset self.channel_filter = channel_filter = firdes.complex_band_pass( 1.0, usrp_rate, -3000, 3000, 2000, window.WIN_HAMMING, 6.76) self.center_freq = center_freq = 144.92e6 self.baud = baud = 1 / 0.022 ################################################## # Blocks ################################################## self._rf_gain_range = Range(0, 76, 1, 9, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", int, QtCore.Qt.Horizontal) self.top_layout.addWidget(self._rf_gain_win) self._center_freq_range = Range(144.0e6, 148.0e6, 1.0e3, 144.92e6, 200) self._center_freq_win = RangeWidget(self._center_freq_range, self.set_center_freq, "Tuning", "counter_slider", float, QtCore.Qt.Horizontal) self.top_layout.addWidget(self._center_freq_win) self.zeromq_pull_msg_source_0 = zeromq.pull_msg_source( 'tcp://127.0.0.1:50251', 100, False) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), '', ) self.uhd_usrp_sink_0.set_samp_rate(usrp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec(0)) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(200000, 0) self.uhd_usrp_sink_0.set_gain(rf_gain, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 1, #number of inputs None # parent ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1.5) 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_NORM, qtgui.TRIG_SLOPE_NEG, 0.5, 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(True) 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.qwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, channel_filter, 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.epy_block_0_0 = epy_block_0_0.mc_sync_block() self.blocks_vco_c_0 = blocks.vco_c(samp_rate, 15708, 0.75) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex * 1, (int)(usrp_rate / samp_rate)) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, repeat) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff(inp_amp) self.blocks_add_const_vxx_0 = blocks.add_const_ff(vco_offset) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_pull_msg_source_0, 'out'), (self.epy_block_0_0, 'msg_in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_vco_c_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.epy_block_0_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0))