def __init__(self): gr.top_block.__init__(self, "Tx Ofdm") ################################################## # Variables ################################################## self.tx_gain = tx_gain = 60 self.samp_rate = samp_rate = 500e3 self.packet_len = packet_len = 60 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 2.4e9 self.fft_len = fft_len = 120 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.3", "")), 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(freq, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=32, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False, ) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, "packet_len") 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/GNURadio-Files/file_tx.txt", 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.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, min_tx_len): gr.top_block.__init__(self, "OFDMChatApp") # Variables self.samp_rate = samp_rate = 1e6 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 self.min_tx_len = min_tx_len self.pdu_port = pmt.intern("pdus") # Blocks self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(400e6, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True ) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0)) self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") ################################################## # Variables ################################################## self.pilot_carriers = pilot_carriers = ((-42, -14, -7, 7, 14, 42), ) self.pattern2 = pattern2 = [1, -1, 1, -1] self.pattern1 = pattern1 = [0., 1.41421356, 0., -1.41421356] self.fft_len = fft_len = 128 self._xmlrpcport_config = ConfigParser.ConfigParser() self._xmlrpcport_config.read('./default') try: xmlrpcport = self._xmlrpcport_config.getint( "usrp_hydra", "xmlrpcport") except: xmlrpcport = 8084 self.xmlrpcport = xmlrpcport 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._samprate2_config = ConfigParser.ConfigParser() self._samprate2_config.read('./default') try: samprate2 = self._samprate2_config.getfloat( "usrp_hydra", "samprate2") except: samprate2 = 1e6 self.samprate2 = samprate2 self._samprate1_config = ConfigParser.ConfigParser() self._samprate1_config.read('./default') try: samprate1 = self._samprate1_config.getfloat( "usrp_hydra", "samprate1") except: samprate1 = 1e6 self.samprate1 = samprate1 self._samprate_config = ConfigParser.ConfigParser() self._samprate_config.read('./default') try: samprate = self._samprate_config.getfloat("usrp_hydra", "samprate") except: samprate = 4e6 self.samprate = samprate self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = ((-1, 1, 1, -1, -1, -1), ) self.packet_len = packet_len = 100 self.occupied_carriers = occupied_carriers = (sorted( tuple( set([x for x in range(-26, 27)]) - set(pilot_carriers[0]) - set([ 0, ]))), ) self.length_tag_key = length_tag_key = "packet_len" self._ip_config = ConfigParser.ConfigParser() self._ip_config.read('./default') try: ip = self._ip_config.get("usrp_hydra", "ip") except: ip = 'localhost' self.ip = ip self._freq2_config = ConfigParser.ConfigParser() self._freq2_config.read('./default') try: freq2 = self._freq2_config.getfloat("usrp_hydra", "txfreq2") except: freq2 = 950.4e6 self.freq2 = freq2 self._freq1_config = ConfigParser.ConfigParser() self._freq1_config.read('./default') try: freq1 = self._freq1_config.getfloat("usrp_hydra", "txfreq1") except: freq1 = 948.6e6 self.freq1 = freq1 self._freq_config = ConfigParser.ConfigParser() self._freq_config.read('./default') try: freq = self._freq_config.getfloat("usrp_hydra", "freq") except: freq = 950e6 self.freq = freq self._amplitude2_config = ConfigParser.ConfigParser() self._amplitude2_config.read('./default') try: amplitude2 = self._amplitude2_config.getfloat( "usrp_hydra", "amplitude2") except: amplitude2 = 0.1 self.amplitude2 = amplitude2 self._amplitude1_config = ConfigParser.ConfigParser() self._amplitude1_config.read('./default') try: amplitude1 = self._amplitude1_config.getfloat( "usrp_hydra", "amplitude1") except: amplitude1 = 0.1 self.amplitude1 = amplitude1 ################################################## # Blocks ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer( (ip, 8084), 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() self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samprate) self.uhd_usrp_sink_1.set_center_freq(freq, 0) self.uhd_usrp_sink_1.set_normalized_gain(1, 0) self.uhd_usrp_sink_1.set_antenna('TX/RX', 0) self.hydra_hydra_sink_0 = hydra.hydra_sink(2, 1024, freq, samprate, ( (freq1, samprate1), (freq2, samprate2), )) self.digital_ofdm_tx_0_1 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key=length_tag_key, occupied_carriers=(sorted( tuple( set([x for x in range(-26, 26)]) - set(pilot_carriers[0]) - set([ 0, ]))), ), pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=[ 0., 0., 0., 0., 0., 0., ] + pattern1 * ((64 - 12) / len(pattern1)) + [ 0., 0., 0., 0., 0., 0., ], sync_word2=[ 0., 0., 0., 0., 0., 0., ] + pattern2 * ((64 - 12) / len(pattern2)) + [ 0., 0., 0., 0., 0., 0., ], bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=128, cp_len=16, packet_length_tag_key=length_tag_key, occupied_carriers=(sorted( tuple( set([x for x in range(-60, 60)]) - set(pilot_carriers[0]) - set([ 0, ]))), ), pilot_carriers=pilot_carriers, pilot_symbols=pilot_symbols, sync_word1=sync_word1, sync_word2=sync_word2, bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False) self.blocks_stream_to_tagged_stream_0_1 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len / 2, length_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (amplitude2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (amplitude1, )) self.analog_random_source_x_0_1 = blocks.vector_source_b( map(int, numpy.random.randint(5, 10, 1000)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 5, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.analog_random_source_x_0_1, 0), (self.blocks_stream_to_tagged_stream_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.hydra_hydra_sink_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.hydra_hydra_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_1, 0), (self.digital_ofdm_tx_0_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0_1, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.hydra_hydra_sink_0, 0), (self.uhd_usrp_sink_1, 0))
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=1000 ): 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.0, 0.0, 0.0, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 0.0, 0.0, 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_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ipp3 + ":55530", 100, True) 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_push_sink_0_0_0 = zeromq.push_sink(gr.sizeof_char, 1, "tcp://" + ipp1 + ":55511", 100, True) self.zeromq_push_sink_0_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + ipp1 + ":55510", 100, True) self.zeromq_push_sink_0 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + iptx + ":55500", 100, True) self.zeromq_pull_source_0_0_0_0_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55521", 100, True ) self.zeromq_pull_source_0_0_0_0_0 = zeromq.pull_source( gr.sizeof_gr_complex, 64, "tcp://" + ipp2 + ":55520", 100, True ) self.zeromq_pull_source_0_0_0_0 = zeromq.pull_source(gr.sizeof_char, 1, "tcp://" + ipp3 + ":55530", 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_source_0 = zeromq.pull_source(gr.sizeof_gr_complex, 1, "tcp://" + iptx + ":55500", 100, True) self.my_random_source_limit_rate_0 = my.random_source_limit_rate(1000) self.my_number_sync_timestamp_0 = my.number_sync_timestamp() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=True, scramble_bits=False, ) 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_chanest_vcvc_0 = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) 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, () ) 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.channels_channel_model_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=0 * 1.0 / fft_len, epsilon=1.0, taps=(1.0,), noise_seed=0, block_tags=True, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) 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, packet_length_tag_key ) 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_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_xx_0, 0), (self.zeromq_push_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.zeromq_push_sink_0_0_1_0_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.blocks_tag_debug_1, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.my_number_sync_timestamp_0, 0)) 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.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_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.zeromq_push_sink_0_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.fft_vxx_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.my_random_source_limit_rate_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.zeromq_pull_source_0, 0), (self.digital_ofdm_sync_sc_cfb_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)) self.connect((self.zeromq_pull_source_0_0_0_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.zeromq_pull_source_0_0_0_0_0, 0), (self.fft_vxx_0, 0)) self.connect((self.zeromq_pull_source_0_0_0_0_0_0, 0), (self.fft_vxx_1, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Rx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Rx") 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", "rx_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 = "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.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.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 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 "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) 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 = qtgui.time_sink_f( 200, #size samp_rate, #samp_rate "", #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, 2) 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(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) 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_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 200, #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, 2) 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 = ['', '', '', '', '', '', '', '', '', ''] 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.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 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=True, scramble_bits=False) 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_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( (sync_word1), (sync_word2), 1, 0, 3, False) 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(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.channels_channel_model_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_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) 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, packet_length_tag_key) self.blocks_repack_bits_bb_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 = 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_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) ################################################## # 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.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_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0, 0)) 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.blocks_uchar_to_float_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)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 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_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_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_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.fft_vxx_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_phase_finder_vci_0, 0), (self.meu_qpsk_demod_adapt_cb_0, 1)) self.connect((self.meu_qpsk_demod_adapt_cb_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "TX OFDM") Qt.QWidget.__init__(self) self.setWindowTitle("TX OFDM") 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_papr") 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.fft_len = fft_len = 256 self.fft2 = fft2 = int(fft_len / 2) 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(-fft2, 0)) + list(range(1, fft2 + 1)), ) self.num_syms = num_syms = 16 self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.tx_amp = tx_amp = 1 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 = 1e6 self.rx_gain = rx_gain = 30 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.packet_len = packet_len = int(96 / 8 * num_syms) self.offset = offset = 8 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_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.freqc = freqc = 900e6 self.frame_len = frame_len = 4096 ################################################## # Blocks ################################################## self._tx_amp_range = Range(0, 2, .001, 1, 200) self._tx_amp_win = RangeWidget(self._tx_amp_range, self.set_tx_amp, 'TX Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_amp_win, 1, 0, 1, 8) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self._rx_gain_range = Range(0, 64, 1, 30, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 8) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.wes_max_ff_0 = wes.max_ff(frame_len) self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_1.set_update_time(0.10) self.qtgui_number_sink_0_1.set_title('PAPR (dB)') 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_0_1.set_min(i, -1) self.qtgui_number_sink_0_1.set_max(i, 1) self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_1.enable_autoscale(False) self._qtgui_number_sink_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_1_win, 11, 4, 1, 4) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title('PAPR') 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_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, 11, 0, 1, 4) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate * 2, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-120, -40) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(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 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, 2, 0, 8, 8) for r in range(2, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.iio_pluto_source_0 = iio.pluto_source('usb:1.4.5', int(freqc), int(samp_rate * 2), 20000000, 32768, True, True, True, 'manual', rx_gain, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('usb:1.3.5', int(freqc), int(samp_rate), 20000000, 32768, False, 10.0, '', True) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len // 4, packet_length_tag_key=packet_length_tag_key, occupied_carriers=occupied_carriers, bps_header=2, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 1, 1, 1), True, 1, []) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp / 30) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff( frame_len, 1 / frame_len, frame_len * 4, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( frame_len, 1 / frame_len, frame_len * 4, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.wes_max_ff_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_number_sink_0_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.wes_max_ff_0, 0), (self.blocks_divide_xx_0, 0))
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.0, 0.0, 0.0, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, -1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 1.41421356, 0.0, 0.0, 0.0, 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 = zeromq.push_sink(gr.sizeof_gr_complex, 1, "tcp://" + iptx + ":55500", 100, True) self.my_random_source_limit_rate_0 = my.random_source_limit_rate(10000000) self.my_number_sync_timestamp_0 = my.number_sync_timestamp() self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=True, scramble_bits=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0,), noise_seed=0, block_tags=False ) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key ) (self.blocks_stream_to_tagged_stream_0).set_max_output_buffer(1) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.my_number_sync_timestamp_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.zeromq_push_sink_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.my_random_source_limit_rate_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "recursion") Qt.QWidget.__init__(self) self.setWindowTitle("recursion") 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", "experiment2") 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)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.length = length = 96 ################################################## # Blocks ################################################## self.timesvl_TimeSVL_2_0 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/output_time_map2_1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/output_2_1.txt' ) self.timesvl_TimeSVL_2 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/output_time_map2_2.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/output_2_2.txt' ) self.timesvl_TimeSVL_1 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map2_2.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_2_2.txt' ) self.timesvl_TimeSVL_0 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map2_1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_2_1.txt' ) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Real spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(True) self.qtgui_time_sink_x_1_0.enable_grid(True) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['Byte', '', '', '', '', '', '', '', '', ''] 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_1_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_win, 2, 0, 1, 8) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 8)] self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Virtual spectrum 1", #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(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 = ['Byte', '', '', '', '', '', '', '', '', ''] 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_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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, 1, 0, 1, 7) [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, 7)] self.qtgui_time_sink_x_0_2 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Demodulated GMSK Data", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_2.set_update_time(0.10) self.qtgui_time_sink_x_0_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_2.enable_tags(-1, True) self.qtgui_time_sink_x_0_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_2.enable_autoscale(True) self.qtgui_time_sink_x_0_2.enable_grid(True) self.qtgui_time_sink_x_0_2.enable_axis_labels(True) self.qtgui_time_sink_x_0_2.enable_control_panel(False) self.qtgui_time_sink_x_0_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_2.disable_legend() labels = ['Bytes', '', '', '', '', '', '', '', '', ''] 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_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_2_win = sip.wrapinstance( self.qtgui_time_sink_x_0_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_2_win, 3, 0, 1, 8) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 8)] self.qtgui_time_sink_x_0_1 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "GMSK Modulated Signal", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(True) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 1, 7, 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(7, 8)] self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "OFDM", #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(-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(True) 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(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, 0, 0, 1, 4) [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, 4)] self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 512, #size samp_rate, #samp_rate "Constant source", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 0, 4, 1, 3) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(4, 7)] self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=16, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.75, mu=0.5, omega_relative_limit=0.025, freq_error=0.0, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, length, "length") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (2.0 / 4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_1 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/TCD 2018-2019/4E2 Final year project/gr-mysvl/examples/inputs/Memory_and_Forgetting.mp3', True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/TCD 2018-2019/4E2 Final year project/gr-mysvl/examples/inputs/Memory_and_Forgetting.mp3', True) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/outputs/output_audio1.mp3', False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/outputs/output_audio2.mp3', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code='', threshold=1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.5) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_const_source_x_0, 0), (self.timesvl_TimeSVL_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blks2_packet_encoder_1, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_2, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_1, 0), (self.blks2_packet_encoder_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.timesvl_TimeSVL_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.timesvl_TimeSVL_1, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.timesvl_TimeSVL_1, 0)) self.connect((self.timesvl_TimeSVL_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.timesvl_TimeSVL_1, 0), (self.timesvl_TimeSVL_2, 0)) self.connect((self.timesvl_TimeSVL_2, 1), (self.digital_gmsk_demod_0, 0)) self.connect((self.timesvl_TimeSVL_2, 0), (self.timesvl_TimeSVL_2_0, 0)) self.connect((self.timesvl_TimeSVL_2_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.timesvl_TimeSVL_2_0, 0), (self.digital_ofdm_rx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm03") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm03") 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", "ofdm03") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.timing = timing = 1.0001 self.samp_rate = samp_rate = 32000 self.packet_len = packet_len = 50 self.noise = noise = 0.01 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 0.01 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self._timing_layout = Qt.QVBoxLayout() self._timing_tool_bar = Qt.QToolBar(self) self._timing_layout.addWidget(self._timing_tool_bar) self._timing_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._timing_counter = qwt_counter_pyslot() self._timing_counter.setRange(0.999, 1.001, 0.0001) self._timing_counter.setNumButtons(2) self._timing_counter.setValue(self.timing) self._timing_tool_bar.addWidget(self._timing_counter) self._timing_counter.valueChanged.connect(self.set_timing) self._timing_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_slider.setRange(0.999, 1.001, 0.0001) self._timing_slider.setValue(self.timing) self._timing_slider.setMinimumWidth(200) self._timing_slider.valueChanged.connect(self.set_timing) self._timing_layout.addWidget(self._timing_slider) self.top_grid_layout.addLayout(self._timing_layout, 2,0,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_tool_bar = Qt.QToolBar(self) self._noise_layout.addWidget(self._noise_tool_bar) self._noise_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_counter = qwt_counter_pyslot() self._noise_counter.setRange(0, 1, 0.01) self._noise_counter.setNumButtons(2) self._noise_counter.setValue(self.noise) self._noise_tool_bar.addWidget(self._noise_counter) self._noise_counter.valueChanged.connect(self.set_noise) self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 1, 0.01) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 1,0,1,1) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(-1, 1, 0.01) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(-1, 1, 0.01) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 1,1,1,1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.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, 0,1,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI 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(-80, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, 10.0/samp_rate, False, 4.0, 0, (-0.0025, -0.00125, 0.0, 0.00125, 0.0025, 0.00375, 0.005, 0.00625, 0.0075, 0.00875, 0.01, 0.01125, 0.0125, 0.015, 0.01625, 0.0175, 0.01875, 0.02, 0.02125, 0.0225, 0.02375, 0.025, 0.0275, 0.02875, 0.03, 0.03125, 0.0325, 0.03375, 0.035, 0.03625, 0.0375, 0.03875, 0.04, 0.04125, 0.0425, 0.04375, 0.045, 0.04625, 0.0475, 0.05125, 0.0525, 0.055, 0.05625, 0.0575, 0.06, 0.06375, 0.065, 0.06625, 0.0675, 0.06875, 0.0725, 0.08, 0.08125, 0.085, 0.08625, 0.0875, 0.08875, 0.09125, 0.0925, 0.09375, 0.095, 0.09875, 0.1, 0.1075, 0.10875, 0.11, 0.11125, 0.13125, 0.1325), (0.16529889, 0.46954084, 0.58274825, 0.24561255, 0.50459457, 0.69767633, 1.0, 0.77724474, 0.48675226, 0.46954084, 0.21267289, 0.19090106, 0.31600413, 0.45293801, 0.8057353, 0.64920938, 0.50459457, 0.1978987, 0.35204369, 0.54226525, 0.31600413, 0.15945397, 0.2204686, 0.35204369, 0.37832563, 0.37832563, 0.36494815, 0.2204686, 0.17763933, 0.45293801, 0.52309091, 0.52309091, 0.46954084, 0.35204369, 0.40656966, 0.25461568, 0.23692776, 0.32758753, 0.1978987, 0.21267289, 0.2204686, 0.19090106, 0.24561255, 0.17135806, 0.21267289, 0.16529889, 0.2204686, 0.30483032, 0.33959553, 0.18415085, 0.18415085, 0.22855006, 0.2940516, 0.19090106, 0.17135806, 0.18415085, 0.1978987, 0.17763933, 0.15945397, 0.26394884, 0.24561255, 0.21267289, 0.19090106, 0.17763933, 0.2204686, 0.21267289, 0.17135806, 0.17135806, 0.16529889), 8 ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq, epsilon=timing, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*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, len_tag_key) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_selective_fading_model_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_selective_fading_model_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Loopback Example") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Loopback Example") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "ofdm_loopback_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.packet_len = packet_len = 192 self.noise_voltage = noise_voltage = 0.1 self.len_tag_key = len_tag_key = "packet_len" self.freq_offset = freq_offset = 0 self.freq = freq = 910e6 self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "FFT Plot", #name 3 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(True) self.qtgui_freq_sink_x_0_0_0.enable_grid(True) self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.05) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win) self._noise_voltage_range = Range(0, 1, .01, 0.1, 200) self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, "Noise Amplitude", "counter_slider", float) self.top_layout.addWidget(self._noise_voltage_win) self.fullduplex_SI_canceller_0 = fullduplex.SI_canceller(10) self._freq_offset_range = Range(-3, 3, .01, 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_layout.addWidget(self._freq_offset_win) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, len_tag_key) 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/k/index4.jpeg", True) self.blocks_file_sink_2_0_1_0_0_0_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, "/home/k/youngmin/files/log_Source", False) self.blocks_file_sink_2_0_1_0_0_0_0.set_unbuffered(True) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, "/home/k/test1", False) self.blocks_file_sink_0_0.set_unbuffered(True) ################################################## # 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_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.fullduplex_SI_canceller_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_freq_sink_x_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.blocks_file_sink_0_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_gate_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fullduplex_SI_canceller_0, 0), (self.blocks_file_sink_2_0_1_0_0_0_0, 0)) self.connect((self.fullduplex_SI_canceller_0, 1), (self.qtgui_freq_sink_x_0_0_0, 2)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.fullduplex_SI_canceller_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0_0_0, 1))
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.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.sro = sro = 0 self.samp_rate = samp_rate = 500000 self.samp_per_sym = samp_per_sym = 2 self.rolloff = rolloff = 0 self.pream = pream = (mapper.preamble_generator(32, 511, 1033)).get_preamble() 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, ) self.frame_width_with_crc32 = frame_width_with_crc32 = 2016 + 32 + 32 self.frame_width = frame_width = 1024 * 2 self.cfo = cfo = 1e-2 self.SNR = SNR = 15 ################################################## # Blocks ################################################## self._sro_range = Range(-1e-1, 1e-1, 1e-3, 0, 200) self._sro_win = RangeWidget(self._sro_range, self.set_sro, 'Sample Rate Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._sro_win) self._cfo_range = Range(-1e-1, 1e-1, 1e-3, 1e-2, 200) self._cfo_win = RangeWidget(self._cfo_range, self.set_cfo, 'Freq Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._cfo_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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 = ['', '', '', '', '', '', '', '', '', ''] 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_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Tx Spectrum', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_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(-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 = ['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.mapper_prbs_source_b_0 = mapper.prbs_source_b( "PRBS31", packet_len) self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS31", packet_len) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=True, scramble_bits=False) 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.channels_channel_model_0 = channels.channel_model( noise_voltage=0.1, frequency_offset=cfo, epsilon=1.0 + sro, taps=(1.0, ), noise_seed=0, block_tags=True) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self._SNR_tool_bar = Qt.QToolBar(self) self._SNR_tool_bar.addWidget(Qt.QLabel('SNR' + ": ")) self._SNR_line_edit = Qt.QLineEdit(str(self.SNR)) self._SNR_tool_bar.addWidget(self._SNR_line_edit) self._SNR_line_edit.returnPressed.connect(lambda: self.set_SNR( eng_notation.str_to_num(str(self._SNR_line_edit.text().toAscii()))) ) self.top_grid_layout.addWidget(self._SNR_tool_bar) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_uchar_to_float_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.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.mapper_prbs_sink_b_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM PU Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM PU Phy") 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_newv") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.taps = taps = filter.firdes.low_pass(1,samp_rate, 0.98e6,0.5e6) 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.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.len_tag_key = len_tag_key = "packet_len" self.interp_factor = interp_factor = 5 self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 1 ################################################## # Blocks ################################################## 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(1255e6, 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False ) self.dbconnect_packet_controller_0 = dbconnect.packet_controller(samp_rate/interp_factor, (10000,), 5, 10, 2, 20, 10, 5, 6643, 30000, (10,20,30), (0,1,2), True) self.dbconnect_cmd_pktgen_0 = dbconnect.cmd_pktgen("127.0.0.1", 5002, 64, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.09, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_2 = blocks.add_vcc(1) self.analog_sig_source_x_0_3 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0) self.analog_sig_source_x_0_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_packet_controller_0, 'in0')) self.msg_connect((self.dbconnect_cmd_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_packet_controller_0, 'gcmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.dbconnect_cmd_pktgen_0, 'cmd')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1)) self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2)) self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.dbconnect_packet_controller_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_packet_controller_0, 1), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_packet_controller_0, 2), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_packet_controller_0, 3), (self.rational_resampler_xxx_0_0_1_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))
def __init__(self): gr.top_block.__init__(self, "Example3") Qt.QWidget.__init__(self) self.setWindowTitle("Example3") 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", "example3") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.udp_len = udp_len = 1472*8 self.time_preamble = time_preamble = [0.125000+0.000000j, 0.522104-0.148216j, -0.495528+0.114832j, -0.267916+0.091700j, 0.236544-0.138456j, -0.098500+0.473800j, 0.476480-0.225344j, -0.187516+0.035372j, 0.051776-0.353552j, -0.104936+0.059916j, 0.228684+0.117504j, -0.530912+0.560756j, 0.359128+0.015872j, -0.132852+0.632840j, -0.105164-0.368872j, 0.368272-0.032412j, 0.125000+0.750000j, 0.463968+0.457792j, 0.151476-0.430948j, 0.685052+0.238524j, 0.494428+0.119428j, -0.557540-0.050056j, 0.416348+0.017368j, 0.104256-0.568836j, -0.301776-0.353552j, 0.079812+0.451516j, 0.439152+0.528072j, 0.642060+0.178484j, -0.090096+0.465096j, -0.446492+0.305776j, -0.111440-0.093688j, -0.538848-0.320228j, 0.125000+0.000000j, -0.538848+0.320228j, -0.111440+0.093688j, -0.446492-0.305776j, -0.090096-0.465096j, 0.642060-0.178484j, 0.439152-0.528072j, 0.079812-0.451516j, -0.301776+0.353552j, 0.104256+0.568836j, 0.416348-0.017368j, -0.557540+0.050056j, 0.494428-0.119428j, 0.685052-0.238524j, 0.151476+0.430948j, 0.463968-0.457792j, 0.125000-0.750000j, 0.368272+0.032412j, -0.105164+0.368872j, -0.132852-0.632840j, 0.359128-0.015872j, -0.530912-0.560756j, 0.228684-0.117504j, -0.104936-0.059916j, 0.051776+0.353552j, -0.187516-0.035372j, 0.476480+0.225344j, -0.098500-0.473800j, 0.236544+0.138456j, -0.267916-0.091700j, -0.495528-0.114832j, 0.522104+0.148216j] self.time_offset2 = time_offset2 = 1 self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 400000 self.preamble_len = preamble_len = 64 self.packet_len = packet_len = 1024 self.number_len = number_len = 64*3 self.noise2 = noise2 = 0 self.noise = noise = 0 self.length = length = 96 self.freq_offset2 = freq_offset2 = 0 self.freq_offset = freq_offset = 0 ################################################## # Blocks ################################################## self._time_offset2_range = Range(0.95, 1.05, 0.00001, 1, 200) self._time_offset2_win = RangeWidget(self._time_offset2_range, self.set_time_offset2, "Time offset", "counter_slider", float) self.top_layout.addWidget(self._time_offset2_win) self._time_offset_range = Range(0.95, 1.05, 0.00001, 1, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, "Time offset", "counter_slider", float) self.top_layout.addWidget(self._time_offset_win) self._noise2_range = Range(0, 0.2, 0.0001, 0, 200) self._noise2_win = RangeWidget(self._noise2_range, self.set_noise2, "Noise", "counter_slider", float) self.top_layout.addWidget(self._noise2_win) self._noise_range = Range(0, 0.2, 0.0001, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "Noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self._freq_offset2_range = Range(0, 0.05, 0.0001, 0, 200) self._freq_offset2_win = RangeWidget(self._freq_offset2_range, self.set_freq_offset2, "Freq offset", "counter_slider", float) self.top_layout.addWidget(self._freq_offset2_win) self._freq_offset_range = Range(0, 0.05, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "Freq offset", "counter_slider", float) self.top_layout.addWidget(self._freq_offset_win) self.mysvl_svl_1 = mysvl.svl(gr.sizeof_gr_complex*1, 1, "./inputs/spectrum_maps/one_many_tx.txt", "./inputs/parameters/one_many_tx.txt") self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="length", bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=noise2, frequency_offset=freq_offset2, epsilon=time_offset2, taps=(1+1j, ), noise_seed=0, block_tags=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1+1j, ), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_1_0 = blocks.vector_source_b(range(1,65), True, 1, []) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_c(time_preamble, True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_c(time_preamble, True, 1, []) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, "127.0.0.2", 4000, udp_len, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, "127.0.0.1", 4000, udp_len, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len, packet_len)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len,packet_len)) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, "./inputs/Memory_and_Forgetting.mp3", True) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=1, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_stream_mux_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.mysvl_svl_1, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_vector_source_x_1_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.mysvl_svl_1, 1), (self.blocks_stream_mux_0, 2)) self.connect((self.mysvl_svl_1, 0), (self.blocks_stream_mux_0_0, 2))
def __init__(self): gr.top_block.__init__(self, "Ofdm05") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm05") 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", "ofdm05") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.timing = timing = 1.0001 self.samp_rate = samp_rate = 7.68e6 self.q_offset = q_offset = 0 self.phase_noise = phase_noise = 0 self.packet_len = packet_len = 50 self.noise = noise = 1.2 self.len_tag_key = len_tag_key = "packet_len" self.iq_ph = iq_ph = 0 self.iq_mag = iq_mag = 0 self.i_offset = i_offset = 0 self.freq = freq = 0.01 self.fft_len = fft_len = 128 self.dist3 = dist3 = 0 self.dist2 = dist2 = 0 ################################################## # Blocks ################################################## self._timing_layout = Qt.QVBoxLayout() self._timing_label = Qt.QLabel("Timing Offset") self._timing_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_slider.setRange(0.999, 1.001, 0.0001) self._timing_slider.setValue(self.timing) self._timing_slider.setMinimumWidth(200) self._timing_slider.valueChanged.connect(self.set_timing) self._timing_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._timing_layout.addWidget(self._timing_label) self._timing_layout.addWidget(self._timing_slider) self.top_grid_layout.addLayout(self._timing_layout, 1,2,1,1) self._q_offset_layout = Qt.QVBoxLayout() self._q_offset_label = Qt.QLabel("Quadrature Offset") self._q_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._q_offset_slider.setRange(-1, 1, 0.01) self._q_offset_slider.setValue(self.q_offset) self._q_offset_slider.setMinimumWidth(200) self._q_offset_slider.valueChanged.connect(self.set_q_offset) self._q_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._q_offset_layout.addWidget(self._q_offset_label) self._q_offset_layout.addWidget(self._q_offset_slider) self.top_grid_layout.addLayout(self._q_offset_layout, 2,3,1,1) self._phase_noise_layout = Qt.QVBoxLayout() self._phase_noise_label = Qt.QLabel("Phase Noise") self._phase_noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_noise_slider.setRange(0, 40, 0.5) self._phase_noise_slider.setValue(self.phase_noise) self._phase_noise_slider.setMinimumWidth(200) self._phase_noise_slider.valueChanged.connect(self.set_phase_noise) self._phase_noise_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_noise_layout.addWidget(self._phase_noise_label) self._phase_noise_layout.addWidget(self._phase_noise_slider) self.top_grid_layout.addLayout(self._phase_noise_layout, 1,3,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_label = Qt.QLabel("Noise Voltage") self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 2, 0.01) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._noise_layout.addWidget(self._noise_label) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 1,0,1,1) self._iq_ph_layout = Qt.QVBoxLayout() self._iq_ph_label = Qt.QLabel("IQ Phase Imbalance") self._iq_ph_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._iq_ph_slider.setRange(-3.14, 3.14, 0.01) self._iq_ph_slider.setValue(self.iq_ph) self._iq_ph_slider.setMinimumWidth(200) self._iq_ph_slider.valueChanged.connect(self.set_iq_ph) self._iq_ph_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._iq_ph_layout.addWidget(self._iq_ph_label) self._iq_ph_layout.addWidget(self._iq_ph_slider) self.top_grid_layout.addLayout(self._iq_ph_layout, 2,1,1,1) self._iq_mag_layout = Qt.QVBoxLayout() self._iq_mag_label = Qt.QLabel("IQ Mag. Imbalance") self._iq_mag_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._iq_mag_slider.setRange(0, 1, 0.01) self._iq_mag_slider.setValue(self.iq_mag) self._iq_mag_slider.setMinimumWidth(200) self._iq_mag_slider.valueChanged.connect(self.set_iq_mag) self._iq_mag_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._iq_mag_layout.addWidget(self._iq_mag_label) self._iq_mag_layout.addWidget(self._iq_mag_slider) self.top_grid_layout.addLayout(self._iq_mag_layout, 2,0,1,1) self._i_offset_layout = Qt.QVBoxLayout() self._i_offset_label = Qt.QLabel("Inphase Offset") self._i_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._i_offset_slider.setRange(-1, 1, 0.01) self._i_offset_slider.setValue(self.i_offset) self._i_offset_slider.setMinimumWidth(200) self._i_offset_slider.valueChanged.connect(self.set_i_offset) self._i_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._i_offset_layout.addWidget(self._i_offset_label) self._i_offset_layout.addWidget(self._i_offset_slider) self.top_grid_layout.addLayout(self._i_offset_layout, 2,2,1,1) self._freq_layout = Qt.QVBoxLayout() self._freq_label = Qt.QLabel("Frequency Offset") self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(-1, 1, 0.01) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_layout.addWidget(self._freq_label) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 1,1,1,1) self._dist3_layout = Qt.QVBoxLayout() self._dist3_label = Qt.QLabel("Third Order Dist") self._dist3_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._dist3_slider.setRange(0, 0.1, 0.0001) self._dist3_slider.setValue(self.dist3) self._dist3_slider.setMinimumWidth(200) self._dist3_slider.valueChanged.connect(self.set_dist3) self._dist3_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._dist3_layout.addWidget(self._dist3_label) self._dist3_layout.addWidget(self._dist3_slider) self.top_grid_layout.addLayout(self._dist3_layout, 3,1,1,1) self._dist2_layout = Qt.QVBoxLayout() self._dist2_label = Qt.QLabel("2nd Order Dist.") self._dist2_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._dist2_slider.setRange(0, 0.1, 0.0001) self._dist2_slider.setValue(self.dist2) self._dist2_slider.setMinimumWidth(200) self._dist2_slider.valueChanged.connect(self.set_dist2) self._dist2_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._dist2_layout.addWidget(self._dist2_label) self._dist2_layout.addWidget(self._dist2_slider) self.top_grid_layout.addLayout(self._dist2_layout, 3,0,1,1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.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, 0,2,1,2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI 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(-80, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,2) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.channels_impairments_0 = channels.impairments(phase_noise, iq_mag, iq_ph, q_offset, i_offset, 0, dist2, dist3) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq, epsilon=timing, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "", "packet_num"); 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, len_tag_key) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.channels_impairments_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.channels_impairments_0, 0)) self.connect((self.channels_impairments_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.channels_impairments_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM PU Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM PU Phy") 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.samp_rate = samp_rate = 10e6 self.taps = taps = filter.firdes.low_pass(1, samp_rate, 0.98e6, 0.5e6) 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.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.len_tag_key = len_tag_key = "packet_len" self.interp_factor = interp_factor = 5 self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 1 ################################################## # Blocks ################################################## 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(pu_params.frequency, 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna(pu_params.antenna, 0) self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.digital_ofdm_tx_0_2 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0_1 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) if type(pu_params.gain) is list and len(pu_params.gain) > 1: gain_incr = pu_params.gain[1] - pu_params.gain[0] gain_max = pu_params.gain[-1] gain_min = pu_params.gain[0] static_gain = -1 else: gain_incr = 0 gain_max = pu_params.gain gain_min = pu_params.gain static_gain = pu_params.gain print "gain range: [", gain_min, ":", gain_incr, ":", gain_max, "]" self.dbconnect_pktgen_0 = dbconnect.pktgen(1, packet_len, False, False, False, pu_params.db_ip, 5003, 5, 10, 2, 20, 50, 100, 60000, 0.05, 6643, gain_min, gain_max, pu_params.gain_period, gain_incr,\ pu_params.scenario,pu_params.channel1,pu_params.channel2,static_gain) # scenario,ch1,ch2,gain. Use -1 for default challenge self.dbconnect_pdu_fillpath_cpp_0_0_1 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0_0_0 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0_0 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0 = dbconnect.pdu_fillpath_cpp() self.blocks_tagged_stream_to_pdu_0_3_1 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0_3_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0_3 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.18, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_2 = blocks.add_vcc(1) self.analog_sig_source_x_0_3 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0) self.analog_sig_source_x_0_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_0, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_1, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0_1, 'in0')) self.msg_connect((self.dbconnect_pktgen_0, 'cmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out1'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out2'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out3'), (self.blocks_pdu_to_tagged_stream_0_0_1, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'cmd'), (self.uhd_usrp_sink_0, 'command')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1)) self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2)) self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.digital_ofdm_tx_0_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_1, 0), (self.digital_ofdm_tx_0_2, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0, 0), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_0, 0), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_1, 0), (self.rational_resampler_xxx_0_0_1_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_3, 0)) self.connect((self.digital_ofdm_tx_0_1, 0), (self.blocks_tagged_stream_to_pdu_0_3_0, 0)) self.connect((self.digital_ofdm_tx_0_2, 0), (self.blocks_tagged_stream_to_pdu_0_3_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Loopback Example") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Loopback Example") 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_loopback_example") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.packet_len = packet_len = 50 self.noise_voltage = noise_voltage = 0.1 self.len_tag_key = len_tag_key = "packet_len" self.freq_offset = freq_offset = 0 self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self._noise_voltage_range = Range(0, 1, .01, 0.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(-3, 3, .01, 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.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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 = ['', '', '', '', '', '', '', '', '', ''] 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_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0 / 10) self._qtgui_sink_x_0_win = sip.wrapinstance( self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) 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(-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 = ['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.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=freq_offset * 1.0 / fft_len, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_vector_source_x_0 = blocks.vector_source_b( range(packet_len), True, 1, ()) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, 'Rx 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, len_tag_key) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_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.blocks_uchar_to_float_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Tx") 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") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.packet_len = packet_len = 100 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("gain" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(400e6, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.fosdem_burst_marker_0 = fosdem.burst_marker( gr.sizeof_gr_complex, len_tag_key, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, len_tag_key, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(packet_len, 0xAA)), 1000) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0)) self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.packet_len = packet_len = 50 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(430000, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_bandwidth(2 * samp_rate, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(430000, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(2 * samp_rate, 0) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "output", #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(-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(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(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_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="packet_len", bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=16, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.blocks_vector_source_x_0 = blocks.vector_source_b( range(packet_len), True, 1, []) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, "packet_len") self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc( (1. / 40, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_2, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_rx_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.samp_rate = samp_rate = 32000 self.packet_len = packet_len = 100 self.len_tag_key = len_tag_key = "packet_len" self.fft_len = fft_len = 32 self.CP_len = CP_len = 4 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 256, #size samp_rate, #samp_rate "Sinal Demodulado", #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.5, -0.5) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['m^(t)', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["green", "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, 1, 1, 1, 1) for r in range(1, 2): 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 = qtgui.time_sink_c( 36, #size samp_rate, #samp_rate "Formas de Onda", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-10, 10) 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) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Re{TX}', 'Im{TX}', 'Re{RX}', 'Im{RX}', '', '', '', '', '', ''] 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(4): 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, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Espectro", #name 2 #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(0.05) 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 = ['TX', 'RX', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=CP_len, packet_length_tag_key='packet_len', occupied_carriers=(list(range(-13,-9))+list(range(-8,-4))+list(range(- 3,0))+list(range(1,4))+list(range(5,9))+list(range(10, 14)),), pilot_carriers=((-9, -4, 4, 9,),), pilot_symbols=((-1, 1, -1, 1,),), bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=CP_len, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", occupied_carriers=(list(range(-13,-9))+list(range(-8,-4))+list(range(- 3,0))+list(range(1,4))+list(range(5,9))+list(range(10, 14)),), pilot_carriers=((-9, -4, 4, 9,),), pilot_symbols=((-1, 1, -1, 1,),), bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0, frequency_offset=0.0, epsilon=1.0, taps=([0, 0, 0, 1, 1, 1]), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "packet_len") self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 10000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.freq = freq = 2375e6 self.udp_len = udp_len = 1472*16 self.time_preamble = time_preamble = [0.125000+0.000000j, 0.522104-0.148216j, -0.495528+0.114832j, -0.267916+0.091700j, 0.236544-0.138456j, -0.098500+0.473800j, 0.476480-0.225344j, -0.187516+0.035372j, 0.051776-0.353552j, -0.104936+0.059916j, 0.228684+0.117504j, -0.530912+0.560756j, 0.359128+0.015872j, -0.132852+0.632840j, -0.105164-0.368872j, 0.368272-0.032412j, 0.125000+0.750000j, 0.463968+0.457792j, 0.151476-0.430948j, 0.685052+0.238524j, 0.494428+0.119428j, -0.557540-0.050056j, 0.416348+0.017368j, 0.104256-0.568836j, -0.301776-0.353552j, 0.079812+0.451516j, 0.439152+0.528072j, 0.642060+0.178484j, -0.090096+0.465096j, -0.446492+0.305776j, -0.111440-0.093688j, -0.538848-0.320228j, 0.125000+0.000000j, -0.538848+0.320228j, -0.111440+0.093688j, -0.446492-0.305776j, -0.090096-0.465096j, 0.642060-0.178484j, 0.439152-0.528072j, 0.079812-0.451516j, -0.301776+0.353552j, 0.104256+0.568836j, 0.416348-0.017368j, -0.557540+0.050056j, 0.494428-0.119428j, 0.685052-0.238524j, 0.151476+0.430948j, 0.463968-0.457792j, 0.125000-0.750000j, 0.368272+0.032412j, -0.105164+0.368872j, -0.132852-0.632840j, 0.359128-0.015872j, -0.530912-0.560756j, 0.228684-0.117504j, -0.104936-0.059916j, 0.051776+0.353552j, -0.187516-0.035372j, 0.476480+0.225344j, -0.098500-0.473800j, 0.236544+0.138456j, -0.267916-0.091700j, -0.495528-0.114832j, 0.522104+0.148216j] self.samp_rate = samp_rate = 1200000 self.preamble_len = preamble_len = 128 self.padding = padding = 12 self.packet_len = packet_len = 1024*4 self.number_len = number_len = 6*4*8 self.new_time_preamble = new_time_preamble = [52.000000 +0.000000j, -5.919279 -8.536566j, -4.260753 -12.607212j,8.939880 -6.125765j,0.884604 -4.096587j,-6.474256 -3.434596j,-4.174710 -0.578714j,3.791506 +1.235053j,0.279833 -0.109122j,5.530533-0.567199j,-1.929208 -7.317350j,-1.378117 +3.190803j,2.805871 -7.702256j,-5.711313 -1.701914j,-2.966432 +1.741682j,-0.247675 +4.490168j,-3.292893 -1.707107j,2.883898 +2.676192j,5.619135 +0.751750j,-4.115069 +2.814674j,-2.589373 -7.294397j,4.612185 +5.259877j,1.197091 +3.742967j,-0.979906 -3.882719j,-1.890878 +1.962808j,4.160219 -3.353154j,-0.540289 +6.005091j,-2.112620 -3.003023j,-3.042150 +2.611726j,1.802848 +4.135673j,5.298560 +4.620461j,0.703246 +3.450126j,5.000000 -1.000000j,5.157142 -0.379740j,3.726040 -3.647292j,-2.997688 +3.323755j,4.889909 -1.616118j,4.836721 +0.468047j,0.992839 -6.866692j,2.704855 -0.610792j,-6.351763 -2.279833j,-1.939613 +0.731610j,7.529818 +3.181252j,-4.310881 -0.784855j,3.354740 -3.048814j,-3.174640 +4.788060j,1.959678 +1.522812j,7.693754 -1.672790j,-4.707107 +0.292893j,5.049252 +3.458181j,1.552404 -4.513244j,3.323670 -1.959693j,-3.571238 +2.200182j,3.211846 +2.977140j,2.428551 -5.636953j,4.723748 +2.769317j,-0.037192 -4.351763j,-4.334488 -2.957252j,2.495908 +3.419032j,3.958268 +0.210689j,-2.732363 -2.667578j,4.275458 -3.511993j,-2.928632 +2.726462j,-1.663484 -3.392583j,2.000000 +0.000000j,-1.663484 +3.392583j,-2.928632 -2.726462j,4.275458 +3.511993j,-2.732363 +2.667578j,3.958268 -0.210689j,2.495908 -3.419032j,-4.334488 +2.957252j,-0.037192 +4.351763j,4.723748 -2.769317j,2.428551 +5.636953j,3.211846 -2.977140j,-3.571238 -2.200182j,3.323670 +1.959693j,1.552404 +4.513244j,5.049252 -3.458181j,-4.707107 -0.292893j,7.693754 +1.672790j,1.959678 -1.522812j,-3.174640 -4.788060j,3.354740 +3.048814j,-4.310881 +0.784855j,7.529818 -3.181252j,-1.939613 -0.731610j,-6.351763 +2.279833j,2.704855 +0.610792j,0.992839 +6.866692j,4.836721 -0.468047j,4.889909 +1.616118j,-2.997688 -3.323755j,3.726040 +3.647292j,5.157142 +0.379740j,5.000000 +1.000000j,0.703246 -3.450126j,5.298560 -4.620461j,1.802848-4.135673j,-3.042150 -2.611726j,-2.112620 +3.003023j,-0.540289 -6.005091j,4.160219 +3.353154j,-1.890878 -1.962808j,-0.979906 +3.882719j,1.197091 -3.742967j,4.612185 -5.259877j,-2.589373 +7.294397j,-4.115069 -2.814674j,5.619135 -0.751750j,2.883898 -2.676192j,-3.292893 +1.707107j,-0.247675 -4.490168j,-2.966432 -1.741682j,-5.711313 +1.701914j,2.805871 +7.702256j,-1.378117 -3.190803j,-1.929208 +7.317350j,5.530533 +0.567199j,0.279833 +0.109122j,3.791506 -1.235053j,-4.174710 +0.578714j,-6.474256 +3.434596j,0.884604 +4.096587j,8.939880 +6.125765j,-4.260753 +12.607212j,-5.919279 +8.536566j] self.length = length = 96 self.gain2 = gain2 = 0.6 self.gain = gain = 0.7 self.freq2 = freq2 = freq+5e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("", "serial= 30C6272")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_subdev_spec("A:B", 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0_0.set_normalized_gain(gain, 0) self.uhd_usrp_sink_0_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "serial=30C628B")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq2, 0) self.uhd_usrp_sink_0.set_normalized_gain(gain2, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_1.set_fft_average(1.0) self.qtgui_freq_sink_x_0_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_1_win, 0, 0, 1, 2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #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_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_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, 1, 0, 1, 1) self.mysvl_svl_1 = mysvl.svl(gr.sizeof_gr_complex*1, 1, "./inputs/spectrum_maps/one_many_tx.txt", "./inputs/parameters/one_many_tx.txt") self.mysvl_stream_demux_0_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,packet_len-2,1), False) self.mysvl_stream_demux_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,packet_len-2,1), False) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="length", bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_1_0 = blocks.vector_source_b(range(1,65), True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_c(new_time_preamble, True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c(new_time_preamble, True, 1, []) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", 3000, 1472, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, packet_len-2,padding+1)) self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, packet_len-2,padding+1)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len, packet_len+2*padding)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len,packet_len+2*padding)) self.blocks_repeat_0_1 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vcc((0.25, )) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc((0.25, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=1, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.mysvl_svl_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_mux_1, 2)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.blocks_repeat_0_0_0, 0), (self.blocks_stream_mux_1_0, 0)) self.connect((self.blocks_repeat_0_1, 0), (self.blocks_stream_mux_1_0, 2)) self.connect((self.blocks_stream_mux_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.blocks_stream_mux_0, 2)) self.connect((self.blocks_stream_mux_1_0, 0), (self.blocks_stream_mux_0_0, 2)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.blocks_vector_source_x_1_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_freq_sink_x_0_1, 0)) self.connect((self.mysvl_stream_demux_0, 2), (self.blocks_repeat_0, 0)) self.connect((self.mysvl_stream_demux_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.mysvl_stream_demux_0, 1), (self.blocks_stream_mux_1, 1)) self.connect((self.mysvl_stream_demux_0_0, 0), (self.blocks_repeat_0_0_0, 0)) self.connect((self.mysvl_stream_demux_0_0, 2), (self.blocks_repeat_0_1, 0)) self.connect((self.mysvl_stream_demux_0_0, 1), (self.blocks_stream_mux_1_0, 1)) self.connect((self.mysvl_svl_1, 0), (self.mysvl_stream_demux_0, 0)) self.connect((self.mysvl_svl_1, 1), (self.mysvl_stream_demux_0_0, 0))
def __init__(self, gain_freq=2, is_noise=0, is_random_source=0, max_gain=0.1, min_gain=0.001, nb_packets=70000, packet_len=400, port=3580, space_between_packets=200, tx_id=0, usrp_tx_gain=3): gr.top_block.__init__(self, "Emitter") ################################################## # Parameters ################################################## self.gain_freq = gain_freq self.is_noise = is_noise self.is_random_source = is_random_source self.max_gain = max_gain self.min_gain = min_gain self.nb_packets = nb_packets self.packet_len = packet_len self.port = port self.space_between_packets = space_between_packets self.tx_id = tx_id self.usrp_tx_gain = usrp_tx_gain ################################################## # Variables ################################################## self.preamble = preamble = ( 0, 1.00000000000000 + 0.00000000000000j, -0.0198821876650702 - 0.999802329770066j, 0.0596151251698190 + 0.998221436781933j, -0.992892073701974 + 0.119018191801903j, -0.980297366804636 + 0.197527397177953j, 0.293850274337919 + 0.955851461405761j, -0.405525320812986 - 0.914083811354038j, 0.848983362091364 - 0.528419578452620j, 0.754564620158230 - 0.656225749270376j, -0.780057308185211 - 0.625708075660561j, 0.888282612749130 + 0.459297289222982j, -0.255616632440464 + 0.966778225458040j, -0.0198821876650804 + 0.999802329770065j, 0.971669340040416 - 0.236344438532879j, -0.869320274439587 + 0.494249188616716j, -0.727878810369485 - 0.685705795086423j, -0.905840393665518 - 0.423619146408540j, -0.0992537989080696 + 0.995062150522427j, -0.255616632440477 - 0.966778225458036j, 0.804316565270771 - 0.594201028971703j, 0.511435479103437 - 0.859321680579653j, -0.992892073701971 - 0.119018191801923j, 0.949820131727787 - 0.312796607022213j, 0.700042074569421 + 0.714101599096754j, 0.949820131727768 + 0.312796607022273j, -0.177997895677522 - 0.984030867978426j, 0.641093637592130 + 0.767462668693983j, -0.331619278552096 + 0.943413299722125j, 0.216978808106213 + 0.976176314419074j, 0.700042074569433 - 0.714101599096743j, -0.177997895677626 + 0.984030867978407j, -0.905840393665558 + 0.423619146408453j, -0.476867501428628 + 0.878975190822367j, 0.987375341936355 - 0.158398024407083j, -0.671098428359002 + 0.741368261698650j, -0.999209397227295 - 0.0397565150970890j, -0.780057308185194 + 0.625708075660582j, 0.987375341936324 + 0.158398024407273j, -0.827304032543040 + 0.561754428320796j, -0.980297366804605 - 0.197527397178109j, -0.827304032543027 + 0.561754428320816j, 0.987375341936332 + 0.158398024407226j, -0.780057308185292 + 0.625708075660460j, -0.999209397227299 - 0.0397565150969950j, -0.671098428359083 + 0.741368261698577j, 0.987375341936350 - 0.158398024407110j, -0.476867501428484 + 0.878975190822446j, -0.905840393665478 + 0.423619146408624j, -0.177997895677642 + 0.984030867978404j, 0.700042074569508 - 0.714101599096669j, 0.216978808106132 + 0.976176314419092j, -0.331619278552151 + 0.943413299722105j, 0.641093637592190 + 0.767462668693933j, -0.177997895677511 - 0.984030867978428j, 0.949820131727754 + 0.312796607022316j, 0.700042074569284 + 0.714101599096888j, 0.949820131727893 - 0.312796607021891j, -0.992892073701961 - 0.119018191802010j, 0.511435479103736 - 0.859321680579474j, 0.804316565270626 - 0.594201028971898j, -0.255616632440350 - 0.966778225458070j, -0.0992537989081486 + 0.995062150522419j, -0.905840393665482 - 0.423619146408617j, -0.727878810369385 - 0.685705795086529j, -0.869320274439717 + 0.494249188616486j, 0.971669340040621 - 0.236344438532038j, -0.0198821876652695 + 0.999802329770062j, -0.255616632440926 + 0.966778225457918j, 0.888282612749188 + 0.459297289222869j, -0.780057308185057 - 0.625708075660753j, 0.754564620158670 - 0.656225749269870j, 0.848983362091728 - 0.528419578452034j, -0.405525320812299 - 0.914083811354343j, 0.293850274337947 + 0.955851461405753j, -0.980297366804665 + 0.197527397177809j, -0.992892073702018 + 0.119018191801536j, 0.0596151251691726 + 0.998221436781972j, -0.0198821876650031 - 0.999802329770067j, 1.00000000000000 + 4.46840285540623e-13j) self.sizes = sizes = struct({ 'zpad': 3000, 'preamble': len(preamble), 'preambleGuard': 40, 'header': 320, 'headerGuard': 100, 'payload': 560, 'payloadGuard': space_between_packets, }) self.samp_rate = samp_rate = 5000000 self.full_header = full_header = sizes.zpad + sizes.preamble + sizes.preambleGuard + sizes.header + sizes.headerGuard self.excess_bw = excess_bw = 0.350 self.center_freq = center_freq = 433e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_clock_source('external', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(usrp_tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.txid_udp_trigger_0 = txid.udp_trigger(tx_id, '0.0.0.0', port) self.txid_head_0 = txid.head(gr.sizeof_gr_complex * 1, full_header, True) self.preamble_vect = blocks.vector_source_c(preamble, True, 1, []) self.digital_psk_mod_1 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=excess_bw, verbose=False, log=False, ) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.blocks_vector_source_x_0_0_0 = blocks.vector_source_b( (tx_id, tx_id, tx_id, tx_id, tx_id), False, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_b( (0, 0, 0, 0, 0xA7), True, 1, []) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, 'packet_len', (full_header + sizes.payload + sizes.payloadGuard) / float(full_header)) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, full_header, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 5, "length") self.blocks_stream_mux_4 = blocks.stream_mux( gr.sizeof_gr_complex * 1, (full_header, sizes.payload, sizes.payloadGuard)) self.blocks_stream_mux_3 = blocks.stream_mux( gr.sizeof_gr_complex * 1, (sizes.zpad, sizes.preamble, sizes.preambleGuard, sizes.header, sizes.headerGuard)) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_null_source_2 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_1_0_0 = blocks.null_source( gr.sizeof_gr_complex * 1) self.blocks_null_source_1_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc(0.05) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=0 if (is_noise) else 1, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=0 if (is_random_source) else 1, output_index=0, ) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_TRI_WAVE, gain_freq, (max_gain - min_gain), min_gain) (self.analog_sig_source_x_0_0).set_max_output_buffer(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, nb_packets)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_UNIFORM, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.txid_udp_trigger_0, 'in')) self.msg_connect((self.txid_udp_trigger_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_noise_source_x_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_psk_mod_1, 0)) self.connect((self.blks2_selector_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_stream_mux_3, 3)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_stream_mux_4, 1)) self.connect((self.blocks_null_source_1, 0), (self.blocks_stream_mux_4, 2)) self.connect((self.blocks_null_source_1_0, 0), (self.blocks_stream_mux_3, 2)) self.connect((self.blocks_null_source_1_0_0, 0), (self.blocks_stream_mux_3, 4)) self.connect((self.blocks_null_source_2, 0), (self.blocks_stream_mux_3, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_stream_mux_4, 0)) self.connect((self.blocks_stream_mux_3, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_stream_mux_4, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.txid_head_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blks2_selector_0, 1)) self.connect((self.blocks_vector_source_x_0_0_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.digital_psk_mod_1, 0), (self.blks2_selector_0_0, 1)) self.connect((self.preamble_vect, 0), (self.blocks_stream_mux_3, 1)) self.connect((self.txid_head_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Link Fd Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Link Fd Gui") 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_link_fd_gui") 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.sync_word_zeros = sync_word_zeros = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.sync_word = sync_word = [ 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.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 32 self.occupied_carriers_len = occupied_carriers_len = len( occupied_carriers[0]) self.variable_function_probe_0_2 = variable_function_probe_0_2 = 0 self.variable_function_probe_0_1_0 = variable_function_probe_0_1_0 = 0 self.variable_function_probe_0_0_1 = variable_function_probe_0_0_1 = 0 self.variable_function_probe_0_0_0_0 = variable_function_probe_0_0_0_0 = 0 self.usrp_source_addr = usrp_source_addr = "addr0=192.168.30.3, addr1=192.168.30.4" self.usrp_sink_addr = usrp_sink_addr = "addr0=192.168.30.3, addr1=192.168.30.4" self.sync_word_zero_len = sync_word_zero_len = len(sync_word_zeros) self.sync_word_len = sync_word_len = len(sync_word) 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.symbols_num = symbols_num = ( packet_len + 4) * 8 / 2 / occupied_carriers_len + 3 self.samp_rate = samp_rate = 5e6 self.premultiply = premultiply = 1 self.pilot_symbols_len = pilot_symbols_len = len(pilot_symbols[0]) self.pilot_carriers_len = pilot_carriers_len = len(pilot_carriers[0]) self.pad_tail_len = pad_tail_len = 1000 self.pad_front_len = pad_front_len = 40000 self.out_buf_size = out_buf_size = 192000 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 915e6 self.frame_len = frame_len = ( (packet_len + 4) / 12 + 3 + 2 + 2 + 2 * 2) * 80 self.fft_len = fft_len = 64 self.delay_tx2rx = delay_tx2rx = 40 ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join((usrp_source_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source.set_clock_source('mimo', 1) self.uhd_usrp_source.set_time_source('mimo', 1) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(freq, 0) self.uhd_usrp_source.set_gain(10, 0) self.uhd_usrp_source.set_antenna('RX2', 0) self.uhd_usrp_source.set_auto_dc_offset(True, 0) self.uhd_usrp_source.set_auto_iq_balance(True, 0) self.uhd_usrp_source.set_center_freq(freq, 1) self.uhd_usrp_source.set_gain(10, 1) self.uhd_usrp_source.set_antenna('RX2', 1) self.uhd_usrp_source.set_auto_dc_offset(True, 1) self.uhd_usrp_source.set_auto_iq_balance(True, 1) self.uhd_usrp_sink = uhd.usrp_sink( ",".join((usrp_sink_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_sink.set_clock_source('mimo', 1) self.uhd_usrp_sink.set_time_source('mimo', 1) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(freq, 0) self.uhd_usrp_sink.set_gain(10, 0) self.uhd_usrp_sink.set_antenna('TX/RX', 0) self.uhd_usrp_sink.set_center_freq(freq, 1) self.uhd_usrp_sink.set_gain(10, 1) self.uhd_usrp_sink.set_antenna('TX/RX', 1) self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Rx Packets') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Rx Signal Spectr') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Estimated Digital Taps') self.top_grid_layout.addWidget(self.tab) def _variable_function_probe_0_2_probe(): while True: val = self.uhd_usrp_sink.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_2(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_2_thread = threading.Thread( target=_variable_function_probe_0_2_probe) _variable_function_probe_0_2_thread.daemon = True _variable_function_probe_0_2_thread.start() def _variable_function_probe_0_1_0_probe(): while True: val = self.uhd_usrp_source.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_1_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_1_0_thread = threading.Thread( target=_variable_function_probe_0_1_0_probe) _variable_function_probe_0_1_0_thread.daemon = True _variable_function_probe_0_1_0_thread.start() def _variable_function_probe_0_0_1_probe(): while True: val = self.uhd_usrp_sink.set_start_time(uhd.time_spec_t(0.5)) try: self.set_variable_function_probe_0_0_1(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_1_thread = threading.Thread( target=_variable_function_probe_0_0_1_probe) _variable_function_probe_0_0_1_thread.daemon = True _variable_function_probe_0_0_1_thread.start() def _variable_function_probe_0_0_0_0_probe(): while True: val = self.uhd_usrp_source.set_start_time(uhd.time_spec_t(0.5)) try: self.set_variable_function_probe_0_0_0_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_0_0_thread = threading.Thread( target=_variable_function_probe_0_0_0_0_probe) _variable_function_probe_0_0_0_0_thread.daemon = True _variable_function_probe_0_0_0_0_thread.start() self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 21 * 1, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.20) self.qtgui_time_sink_x_1.set_y_axis(-0.5, 0.5) 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, 0, 0, "packet_len") 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(True) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = [ 'Est. h for FD node 0 - I', 'Est. h for FD node 0 - Q', 'Est. h for FD node 1 - I', 'Est. h for FD node 1 - Q', '', '', '', '', '', '' ] 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 = [0, 0, 0, 0, -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(4): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( packet_len, #size samp_rate, #samp_rate 'Scope Plot', #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.1) 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(-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(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(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 = ["Radio 1", "Radio 2", '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_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.tab_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.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(True) 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 = ["Radio 1", "Radio 2", '', '', '', '', '', '', '', ''] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.fullduplex_packet_encap2_0_0 = fullduplex.packet_encap2( False, False, 0.001, pad_front_len, pad_tail_len, 1, premultiply, 1) (self.fullduplex_packet_encap2_0_0).set_min_output_buffer(192000) self.fullduplex_packet_encap2_0 = fullduplex.packet_encap2( False, False, 0.001, pad_front_len, pad_tail_len, 0, premultiply, 1) (self.fullduplex_packet_encap2_0).set_min_output_buffer(192000) self.fullduplex_digital_sic_0_0 = fullduplex.digital_sic( False, delay_tx2rx, pad_front_len, 1, frame_len, 10, 1, premultiply) (self.fullduplex_digital_sic_0_0).set_min_output_buffer(192000) self.fullduplex_digital_sic_0 = fullduplex.digital_sic( False, delay_tx2rx, pad_front_len, 0, frame_len, 10, 1, premultiply) (self.fullduplex_digital_sic_0).set_min_output_buffer(192000) self.digital_ofdm_tx_0_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len_tag_key", packet_length_tag_key="rx_len_tag_key", 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_rx_0_0_0).set_min_output_buffer(192000) self.digital_ofdm_rx_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len_tag_key", packet_length_tag_key="rx_len_tag_key", 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_rx_0_0).set_min_output_buffer(192000) self.blocks_vector_source_x_0_0 = blocks.vector_source_b( [0, 1, 2, 3, 4, 3, 2, 1], True, 1, ()) self.blocks_vector_source_x_0 = blocks.vector_source_b( [4, 4, 4, 4, 0, 0, 0, 0], True, 1, ()) self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, 'Rx Packets', "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_1_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, frame_len + pad_front_len + pad_tail_len, "packet_len") (self.blocks_stream_to_tagged_stream_1_0).set_min_output_buffer(192000) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, frame_len + pad_front_len + pad_tail_len, "packet_len") (self.blocks_stream_to_tagged_stream_1).set_min_output_buffer(192000) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, len_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, len_tag_key) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (0.01 * 2.23 * 0.56 * 1.4 * 1.4 * premultiply, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (0.01 * 2.23 * 0.56 * 1.4 * 1.4 * premultiply, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fullduplex_packet_encap2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.fullduplex_packet_encap2_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_ofdm_tx_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fullduplex_digital_sic_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1_0, 0), (self.fullduplex_digital_sic_0_0, 1)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.digital_ofdm_rx_0_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_ofdm_rx_0_0_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_ofdm_rx_0_0_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.fullduplex_digital_sic_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.fullduplex_digital_sic_0, 1), (self.digital_ofdm_rx_0_0, 0)) self.connect((self.fullduplex_digital_sic_0, 1), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.fullduplex_digital_sic_0, 2), (self.qtgui_time_sink_x_1, 0)) self.connect((self.fullduplex_digital_sic_0_0, 0), (self.blocks_null_sink_0_0_0, 1)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.digital_ofdm_rx_0_0_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.fullduplex_digital_sic_0_0, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.fullduplex_digital_sic_0, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.uhd_usrp_sink, 0)) self.connect((self.fullduplex_packet_encap2_0_0, 0), (self.fullduplex_digital_sic_0_0, 0)) self.connect((self.fullduplex_packet_encap2_0_0, 0), (self.uhd_usrp_sink, 1)) self.connect((self.uhd_usrp_source, 0), (self.blocks_stream_to_tagged_stream_1, 0)) self.connect((self.uhd_usrp_source, 1), (self.blocks_stream_to_tagged_stream_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Transceiver") self._lock = threading.RLock() ################################################## # Variables ################################################## self.sent_pkt = 0 self.rcv_pkt = 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_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.waterfall_min = waterfall_min = -80 self.waterfall_max = waterfall_max = -20 self.tx_gain = tx_gain = 0.03 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 = 20e6 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.center_freq = center_freq = 2.412e9 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(samp_rate, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(10, 0) self.osmosdr_sink_0.set_gain(20, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(samp_rate, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=fft_len/4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=True, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=fft_len/4, frame_length_tag_key='frame_'+packet_length_tag_key, packet_length_tag_key=packet_length_tag_key, 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.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(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_const_vxx_0 = blocks.multiply_const_vcc((tx_gain, )) self.blocks_message_debug_0 = blocks.message_debug() self.pdu_block = messaging.pdu_block(self) ################################################## # Connections ################################################## self.msg_connect((self.pdu_block, 'out_pdu'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.pdu_block, 'in_pdu')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Transceiver") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Transceiver") 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", "rx_ofdm") 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.num_syms = num_syms = 1 self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.tx_amp = tx_amp = 0.034 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.sc_select = sc_select = 0 self.samp_rate = samp_rate = 1e6 self.rx_gain = rx_gain = 30 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.packet_len = packet_len = int(96 / 8 * num_syms) self.offset = offset = 8 self.mp_gain = mp_gain = 0 self.mp_delay = mp_delay = 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_static( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, 0, True) self.freqc = freqc = 900e6 self.cp_delay = cp_delay = 0 ################################################## # Blocks ################################################## self._tx_amp_range = Range(0.001, 0.1, .001, 0.034, 200) self._tx_amp_win = RangeWidget(self._tx_amp_range, self.set_tx_amp, 'TX Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._tx_amp_win, 1, 0, 1, 8) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.tab_const = Qt.QTabWidget() self.tab_const_widget_0 = Qt.QWidget() self.tab_const_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_0) self.tab_const_grid_layout_0 = Qt.QGridLayout() self.tab_const_layout_0.addLayout(self.tab_const_grid_layout_0) self.tab_const.addTab(self.tab_const_widget_0, 'Pre-Equalization (Single-Subcarrier)') self.tab_const_widget_1 = Qt.QWidget() self.tab_const_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_1) self.tab_const_grid_layout_1 = Qt.QGridLayout() self.tab_const_layout_1.addLayout(self.tab_const_grid_layout_1) self.tab_const.addTab(self.tab_const_widget_1, 'Pre-Equalization (All Subcarriers)') self.tab_const_widget_2 = Qt.QWidget() self.tab_const_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_const_widget_2) self.tab_const_grid_layout_2 = Qt.QGridLayout() self.tab_const_layout_2.addLayout(self.tab_const_grid_layout_2) self.tab_const.addTab(self.tab_const_widget_2, 'Post-Equalization (All Subcarriers)') self.top_grid_layout.addWidget(self.tab_const, 2, 0, 8, 4) for r in range(2, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._sc_select_range = Range(0, fft_len - 1, 1, 0, 200) self._sc_select_win = RangeWidget(self._sc_select_range, self.set_sc_select, 'Sub Carrier Select', "counter_slider", float) self.top_grid_layout.addWidget(self._sc_select_win, 12, 0, 1, 4) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._rx_gain_range = Range(0, 64, 1, 30, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 8) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self._mp_gain_range = Range(0, 1, 0.001, 0, 200) self._mp_gain_win = RangeWidget(self._mp_gain_range, self.set_mp_gain, 'Multipath Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._mp_gain_win, 13, 0, 1, 4) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._mp_delay_range = Range(0, 32, 1, 0, 200) self._mp_delay_win = RangeWidget(self._mp_delay_range, self.set_mp_delay, 'Multipath Delay (Samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._mp_delay_win, 13, 4, 1, 4) for r in range(13, 14): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self._cp_delay_range = Range(0, 3, 1, 0, 200) self._cp_delay_win = RangeWidget(self._cp_delay_range, self.set_cp_delay, 'CP Delay (samples)', "counter_slider", float) self.top_grid_layout.addWidget(self._cp_delay_win, 12, 4, 1, 4) for r in range(12, 13): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( fft_len, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Channel Response", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-100, 0) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 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, 2, 4, 8, 4) for r in range(2, 10): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_1.set_y_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_1.set_x_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_1.enable_grid(True) self.qtgui_const_sink_x_0_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget) self.tab_const_layout_1.addWidget(self._qtgui_const_sink_x_0_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_const_sink_x_0_0.set_x_axis(-2.5, 2.5) 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) self.qtgui_const_sink_x_0_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_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.tab_const_layout_0.addWidget(self._qtgui_const_sink_x_0_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.5, 2.5) self.qtgui_const_sink_x_0.set_x_axis(-2.5, 2.5) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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.tab_const_layout_2.addWidget(self._qtgui_const_sink_x_0_win) self._num_syms_range = Range(1, 20, 1, 1, 200) self._num_syms_win = RangeWidget(self._num_syms_range, self.set_num_syms, '# of Symbols per Pkt', "counter_slider", float) self.top_grid_layout.addWidget(self._num_syms_win, 11, 0, 1, 8) for r in range(11, 12): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.iio_pluto_source_0 = iio.pluto_source('usb:1.4.5', int(freqc), int(samp_rate), 20000000, 32768, True, True, True, 'manual', rx_gain, '', True) self.iio_pluto_sink_0 = iio.pluto_sink('usb:1.3.5', int(freqc), int(samp_rate), 20000000, 32768, False, 10.0, '', True) self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len // 4, packet_length_tag_key=packet_length_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) 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_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( sync_word1, sync_word2, 1, 0, 3, False) 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", int(samp_rate), (), 0) 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.blocks_vector_to_stream_0_0_1 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char * 1, 'Rx Bytes', "") self.blocks_tag_debug_1.set_display(False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) 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 = 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_1 = blocks.multiply_const_cc(mp_gain) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(tx_amp) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 1, fft_len, sc_select) self.blocks_delay_2 = blocks.delay(gr.sizeof_gr_complex * 1, mp_delay) self.blocks_delay_1 = blocks.delay(gr.sizeof_gr_complex * 1, cp_delay) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.blocks_add_xx_0 = blocks.add_vcc(1) 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, '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.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_1, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_delay_2, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iio_pluto_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) 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_crc32_bb_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_delay_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_1, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_vector_to_stream_0_0_1, 0), (self.qtgui_const_sink_x_0_1, 0)) 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.blocks_tag_debug_1, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.digital_header_payload_demux_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_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_serializer_vcc_payload, 0), (self.qtgui_const_sink_x_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_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.blocks_vector_to_stream_0_0_1, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.iio_pluto_source_0, 0), (self.blocks_delay_2, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Single") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Single") 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", "vr2_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vr2_pc = vr2_pc = ((-14, -7, 7, 14), ) self.vr2_pattern2 = vr2_pattern2 = [1, -1, 1, -1] self.vr2_pattern1 = vr2_pattern1 = [0., 1.41421356, 0., -1.41421356] 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("rx", "xmlrpcport") except: xmlrpcport = 0 self.xmlrpcport = xmlrpcport self.vr2_sw2 = vr2_sw2 = [ 0., 0., 0., 0., 0., 0., ] + vr2_pattern2 * ((fft_len - 12) / len(vr2_pattern2)) + [ 0., 0., 0., 0., 0., 0., ] self.vr2_sw1 = vr2_sw1 = [ 0., 0., 0., 0., 0., 0., ] + vr2_pattern1 * ((fft_len - 12) / len(vr2_pattern1)) + [ 0., 0., 0., 0., 0., 0., ] self.vr2_ps = vr2_ps = ((1, 1, -1, -1), ) self.vr2_oc = vr2_oc = (sorted( tuple( set([x for x in range(-26, 27)]) - set(vr2_pc[0]) - set([ 0, ]))), ) self._usrpip_config = ConfigParser.ConfigParser() self._usrpip_config.read('default') try: usrpip = self._usrpip_config.get("usrp", "ip") except: usrpip = "127.0.0.1" self.usrpip = usrpip self._txoutport_config = ConfigParser.ConfigParser() self._txoutport_config.read('default') try: txoutport = self._txoutport_config.get("usrp", "txoutport") except: txoutport = "2666" self.txoutport = txoutport self.txgain = txgain = 1 self.tx_goodput = tx_goodput = 0 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._samprate_config = ConfigParser.ConfigParser() self._samprate_config.read('default') try: samprate = self._samprate_config.getfloat("usrp_hydra", "samprate2") except: samprate = 4e6 self.samprate = samprate self.rxgain = rxgain = 0 self.rx_goodput = rx_goodput = 0 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._freq_config = ConfigParser.ConfigParser() self._freq_config.read('./default') try: freq = self._freq_config.getfloat("usrp_hydra", "txfreq2") except: freq = 4.4e9 self.freq = freq self.cpu_percent = cpu_percent = 0 self.amplitude = amplitude = 0.01 ################################################## # Blocks ################################################## self._txgain_range = Range(0, 1, 0.01, 1, 200) self._txgain_win = RangeWidget(self._txgain_range, self.set_txgain, 'txgain', "counter_slider", float) self.top_layout.addWidget(self._txgain_win) self._rxgain_range = Range(0, 1, 0.01, 0, 200) self._rxgain_win = RangeWidget(self._rxgain_range, self.set_rxgain, 'rxgain', "counter_slider", float) self.top_layout.addWidget(self._rxgain_win) 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.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() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samprate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rxgain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samprate) self.uhd_usrp_sink_0.set_center_freq(freq + 4e6, 0) self.uhd_usrp_sink_0.set_normalized_gain(txgain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(samprate, 0) def _tx_goodput_probe(): while True: val = self.probe1_1_0.rate() try: self.set_tx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _tx_goodput_thread = threading.Thread(target=_tx_goodput_probe) _tx_goodput_thread.daemon = True _tx_goodput_thread.start() def _rx_goodput_probe(): while True: val = self.probe1_1.rate() try: self.set_rx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _rx_goodput_thread = threading.Thread(target=_rx_goodput_probe) _rx_goodput_thread.daemon = True _rx_goodput_thread.start() self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 100, #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 "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.digital_ofdm_tx_0 = digital.ofdm_tx(fft_len=fft_len, cp_len=16, packet_length_tag_key="vr2tx", occupied_carriers=vr2_oc, pilot_carriers=vr2_pc, pilot_symbols=vr2_ps, sync_word1=vr2_sw1, sync_word2=vr2_sw2, bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=16, frame_length_tag_key='frame_' + "vr2rx", packet_length_tag_key="vr2rx", occupied_carriers=vr2_oc, pilot_carriers=vr2_pc, pilot_symbols=vr2_ps, sync_word1=vr2_sw1, sync_word2=vr2_sw2, bps_header=1, bps_payload=1, debug_log=False, scramble_bits=False) self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc( (([])), 2000, 1000, False, "vr2tx") 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_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, "vr2rx") (self.blocks_tagged_stream_to_pdu_0).set_processor_affinity([1]) self.blocks_tag_debug_0_0 = blocks.tag_debug(gr.sizeof_char * 1, "Tx'd Packets", "") self.blocks_tag_debug_0_0.set_display(True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, "Rx'd Packet", "") self.blocks_tag_debug_0.set_display(True) self.blocks_random_pdu_0_0 = blocks.random_pdu(50, 100, chr(0xFF), 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "vr2tx") self.blocks_pdu_set_0_0 = blocks.pdu_set(pmt.intern("vr2rx"), pmt.intern("generate")) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01, )) self._amplitude_range = Range(0, 1, 0.01, 0.01, 200) self._amplitude_win = RangeWidget(self._amplitude_range, self.set_amplitude, 'amplitude', "counter_slider", float) self.top_layout.addWidget(self._amplitude_win) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_set_0_0, 'pdus'), (self.blocks_random_pdu_0_0, 'generate')) self.msg_connect((self.blocks_random_pdu_0_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_pdu_set_0_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_burst_shaper_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_tag_debug_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.probe1_1_0, 0)) self.connect((self.digital_burst_shaper_xx_0, 0), (self.uhd_usrp_sink_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.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.probe1_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_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") 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)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.length = length = 96 self.gain = gain = 15 self.freq = freq = 2.441e9 ################################################## # Blocks ################################################## self._gain_range = Range(0, 40, 1, 15, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_range = Range(2.4e9, 2.5e9, 1e6, 2.441e9, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_layout.addWidget(self._freq_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(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_bandwidth(1e6, 0) self.timesvl_TimeSVL_0 = timesvl.TimeSVL( gr.sizeof_gr_complex * 1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_1.txt' ) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "GMSK TRANSMITTER", #name 2 #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, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['GMSK Modulated', 'Byte', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 0, 1, 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(1, 2)] self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Transmitted signal", #name 2 #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(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(2): 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, 1, 0, 1, 2) [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, 2)] self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 512, #size samp_rate, #samp_rate "OFDM TRANSMITTER", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['OFDM', 'Byte', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_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.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.3, verbose=False, log=False, ) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, length, "length") self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_1 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', True) self.blocks_complex_to_float_0_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=True, ), payload_length=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.qtgui_time_sink_x_2, 1)) self.connect((self.blocks_complex_to_float_0_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_complex_to_float_0_0_0, 1), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_1, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.timesvl_TimeSVL_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.timesvl_TimeSVL_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.blocks_complex_to_float_0_0_0, 0)) self.connect((self.timesvl_TimeSVL_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Usrp Experiment2 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Usrp Experiment2 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", "usrp_experiment2_tx") 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)) ################################################## # Variables ################################################## self.time_preamble = time_preamble = [0.125000+0.000000j, 0.522104-0.148216j, -0.495528+0.114832j, -0.267916+0.091700j, 0.236544-0.138456j, -0.098500+0.473800j, 0.476480-0.225344j, -0.187516+0.035372j, 0.051776-0.353552j, -0.104936+0.059916j, 0.228684+0.117504j, -0.530912+0.560756j, 0.359128+0.015872j, -0.132852+0.632840j, -0.105164-0.368872j, 0.368272-0.032412j, 0.125000+0.750000j, 0.463968+0.457792j, 0.151476-0.430948j, 0.685052+0.238524j, 0.494428+0.119428j, -0.557540-0.050056j, 0.416348+0.017368j, 0.104256-0.568836j, -0.301776-0.353552j, 0.079812+0.451516j, 0.439152+0.528072j, 0.642060+0.178484j, -0.090096+0.465096j, -0.446492+0.305776j, -0.111440-0.093688j, -0.538848-0.320228j, 0.125000+0.000000j, -0.538848+0.320228j, -0.111440+0.093688j, -0.446492-0.305776j, -0.090096-0.465096j, 0.642060-0.178484j, 0.439152-0.528072j, 0.079812-0.451516j, -0.301776+0.353552j, 0.104256+0.568836j, 0.416348-0.017368j, -0.557540+0.050056j, 0.494428-0.119428j, 0.685052-0.238524j, 0.151476+0.430948j, 0.463968-0.457792j, 0.125000-0.750000j, 0.368272+0.032412j, -0.105164+0.368872j, -0.132852-0.632840j, 0.359128-0.015872j, -0.530912-0.560756j, 0.228684-0.117504j, -0.104936-0.059916j, 0.051776+0.353552j, -0.187516-0.035372j, 0.476480+0.225344j, -0.098500-0.473800j, 0.236544+0.138456j, -0.267916-0.091700j, -0.495528-0.114832j, 0.522104+0.148216j] self.samp_rate = samp_rate = 3.125e6 self.preamble_len = preamble_len = 64 self.padding = padding = 12 self.packet_len = packet_len = 1024 self.length = length = 96 self.gain = gain = 15 self.freq = freq = 2.441e9 ################################################## # Blocks ################################################## self.timesvl_TimeSVL_1 = timesvl.TimeSVL(gr.sizeof_gr_complex*1, 1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Time_maps/input_time_map1.txt', '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/input_1.txt') self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Preamble and transmitted signal", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.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.mysvl_stream_demux_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,1022,1), False) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(2, firdes.low_pass( 1, samp_rate, samp_rate/4-samp_rate/32, samp_rate/32, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, samp_rate/2-samp_rate/32, samp_rate/32, firdes.WIN_HAMMING, 6.76)) self._gain_range = Range(0, 40, 1, 15, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_grid_layout.addWidget(self._gain_win, 0, 2, 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(2,3)] self._freq_range = Range(2.4e9, 2.5e9, 1e6, 2.441e9, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, "freq", "counter_slider", float) self.top_grid_layout.addWidget(self._freq_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.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_c(time_preamble, True, 1, []) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, 1022,padding+1)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, 1048)) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((2.0/4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_1 = blocks.file_source(gr.sizeof_char*1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/media/tamanna/Seagate Expansion Drive/gr-timesvl/examples/Input_Output parameters/Memory_and_Forgetting.mp3', False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blks2_packet_encoder_1_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_1_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_1, 0), (self.blks2_packet_encoder_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_stream_mux_1, 2)) self.connect((self.blocks_stream_mux_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.timesvl_TimeSVL_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.timesvl_TimeSVL_1, 1)) self.connect((self.mysvl_stream_demux_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.mysvl_stream_demux_0, 2), (self.blocks_repeat_0_0, 0)) self.connect((self.mysvl_stream_demux_0, 1), (self.blocks_stream_mux_1, 1)) self.connect((self.timesvl_TimeSVL_1, 0), (self.mysvl_stream_demux_0, 0))
def __init__(self): gr.top_block.__init__(self, "Prr Fd Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Prr Fd Gui") 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", "prr_fd_gui") 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.sync_word_zeros = sync_word_zeros = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.sync_word = sync_word = [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.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.packet_len = packet_len = 32 self.occupied_carriers_len = occupied_carriers_len = len(occupied_carriers[0]) self.variable_function_probe_0_2 = variable_function_probe_0_2 = 0 self.variable_function_probe_0_1_0 = variable_function_probe_0_1_0 = 0 self.variable_function_probe_0_0_1 = variable_function_probe_0_0_1 = 0 self.variable_function_probe_0_0_0_0 = variable_function_probe_0_0_0_0 = 0 self.usrp_source_addr = usrp_source_addr = "addr0=192.168.30.3, addr1=192.168.30.4" self.usrp_sink_addr = usrp_sink_addr = "addr0=192.168.30.3, addr1=192.168.30.4" self.tx_gain = tx_gain = 20 self.sync_word_zero_len = sync_word_zero_len = len(sync_word_zeros) self.sync_word_len = sync_word_len = len(sync_word) 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.symbols_num = symbols_num = (packet_len + 4)*8/2 /occupied_carriers_len + 3 self.samp_rate = samp_rate = 5e6 self.premultiply = premultiply = 1 self.pilot_symbols_len = pilot_symbols_len = len(pilot_symbols[0]) self.pilot_carriers_len = pilot_carriers_len = len(pilot_carriers[0]) self.pad_tail_len = pad_tail_len = 1000 self.pad_front_len = pad_front_len = 320000 self.out_buf_size = out_buf_size = 1000000 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 915e6 self.frame_len = frame_len = ((packet_len+4)/12+3+2 + 2 + 2*2)*80 + 0*80 self.fft_len = fft_len = 64 self.delay_tx2rx = delay_tx2rx = 40 self.bb_gain = bb_gain = -21.5 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 25, 1, 20, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, 'Tx Gain', "counter_slider", int) self.top_grid_layout.addWidget(self._tx_gain_win, 5, 0, 1, 6) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source = uhd.usrp_source( ",".join((usrp_source_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source.set_clock_source('mimo', 1) self.uhd_usrp_source.set_time_source('mimo', 1) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(freq, 0) self.uhd_usrp_source.set_gain(10, 0) self.uhd_usrp_source.set_antenna('RX2', 0) self.uhd_usrp_source.set_auto_dc_offset(True, 0) self.uhd_usrp_source.set_auto_iq_balance(True, 0) self.uhd_usrp_source.set_center_freq(freq, 1) self.uhd_usrp_source.set_gain(10, 1) self.uhd_usrp_source.set_antenna('RX2', 1) self.uhd_usrp_source.set_auto_dc_offset(True, 1) self.uhd_usrp_source.set_auto_iq_balance(True, 1) self.uhd_usrp_sink = uhd.usrp_sink( ",".join((usrp_sink_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_sink.set_clock_source('mimo', 1) self.uhd_usrp_sink.set_time_source('mimo', 1) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(freq, 0) self.uhd_usrp_sink.set_gain(0, 0) self.uhd_usrp_sink.set_antenna('TX/RX', 0) self.uhd_usrp_sink.set_center_freq(freq, 1) self.uhd_usrp_sink.set_gain(tx_gain, 1) self.uhd_usrp_sink.set_antenna('TX/RX', 1) def _variable_function_probe_0_2_probe(): while True: val = self.uhd_usrp_sink.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_2(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_2_thread = threading.Thread(target=_variable_function_probe_0_2_probe) _variable_function_probe_0_2_thread.daemon = True _variable_function_probe_0_2_thread.start() def _variable_function_probe_0_1_0_probe(): while True: val = self.uhd_usrp_source.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_1_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_1_0_thread = threading.Thread(target=_variable_function_probe_0_1_0_probe) _variable_function_probe_0_1_0_thread.daemon = True _variable_function_probe_0_1_0_thread.start() def _variable_function_probe_0_0_1_probe(): while True: val = self.uhd_usrp_sink.set_start_time(uhd.time_spec_t(0.5)) try: self.set_variable_function_probe_0_0_1(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_1_thread = threading.Thread(target=_variable_function_probe_0_0_1_probe) _variable_function_probe_0_0_1_thread.daemon = True _variable_function_probe_0_0_1_thread.start() def _variable_function_probe_0_0_0_0_probe(): while True: val = self.uhd_usrp_source.set_start_time(uhd.time_spec_t(0.5)) try: self.set_variable_function_probe_0_0_0_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_0_0_thread = threading.Thread(target=_variable_function_probe_0_0_0_0_probe) _variable_function_probe_0_0_0_0_thread.daemon = True _variable_function_probe_0_0_0_0_thread.start() self.qtgui_time_sink_x_0 = qtgui.time_sink_c( frame_len, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_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 = ["After RF SIC, I", "After RF SIC, Q", "After Digital SIC, I", "After Digital SIC, Q", '', '', '', '', '', ''] 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(4): 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, 0, 0, 3, 6) for r in range(0, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0_0_0_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0_0_0_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0_0_0_0.set_title("Measured PRR") labels = ["Packet Reception Ratio", '', '', '', '', '', '', '', '', ''] 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_0_0_0_0.set_min(i, 0) self.qtgui_number_sink_0_0_0_0_0.set_max(i, 1) self.qtgui_number_sink_0_0_0_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_0_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_0_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0_0_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0_0_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_0_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_0_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_0_0_0_win, 4, 0, 1, 6) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("Measured SNR") labels = ["Signal-to-Noise Ratio", '', '', '', '', '', '', '', '', ''] units = ["dB", '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 35) 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, 3, 0, 1, 6) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 3*48, #size "Constellation after RF SIC", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) 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(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(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_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0, 7, 3, 3) for r in range(0, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 10): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 3*48, #size "Constellation after Digital SIC", #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, 3, 7, 3, 3) for r in range(3, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(7, 10): self.top_grid_layout.setColumnStretch(c, 1) self.fullduplex_snr_calc_0 = fullduplex.snr_calc(False, 0, -20, 6, 0, 140) self.fullduplex_packet_encap2_0_0 = fullduplex.packet_encap2(False, False, 0.001, pad_front_len, pad_tail_len, 1, 0.2, 2) (self.fullduplex_packet_encap2_0_0).set_min_output_buffer(1000000) self.fullduplex_packet_encap2_0 = fullduplex.packet_encap2(False, False, 0.001, pad_front_len, pad_tail_len, 0, premultiply, 2) (self.fullduplex_packet_encap2_0).set_min_output_buffer(1000000) self.fullduplex_ofdm_constellation_0_0 = fullduplex.ofdm_constellation(False, 8, -20, frame_len) (self.fullduplex_ofdm_constellation_0_0).set_min_output_buffer(1000000) self.fullduplex_ofdm_constellation_0 = fullduplex.ofdm_constellation(False, 0, -20, frame_len) (self.fullduplex_ofdm_constellation_0).set_min_output_buffer(1000000) self.fullduplex_digital_sic_0_0 = fullduplex.digital_sic(False, delay_tx2rx, pad_front_len, 0, frame_len, 10, 1, premultiply) (self.fullduplex_digital_sic_0_0).set_min_output_buffer(1000000) self.fullduplex_count_packets_0_0 = fullduplex.count_packets(False) self.fullduplex_count_packets_0 = fullduplex.count_packets(False) self.fullduplex_async_divide_0 = fullduplex.async_divide() self.digital_ofdm_tx_0_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0_0_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len_tag_key", packet_length_tag_key="rx_len_tag_key", 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_rx_0_0_0).set_min_output_buffer(1000000) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, frame_len + pad_front_len + pad_tail_len, "packet_len") (self.blocks_stream_to_tagged_stream_1).set_min_output_buffer(1000000) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key) self.blocks_null_sink_3_1_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_3_1_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_3_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_3 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((0.01*2.23 * 0.56 * 1.4 * 1.4 * premultiply * 10**(bb_gain/20.0), )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01*2.23 * 0.56 * 1.4 * 1.4 * premultiply * 10 ** (-5.0/20), )) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.analog_random_source_x_0_0 = blocks.vector_source_b(map(int, numpy.random.randint(51, 100, 50)), True) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 50, 50)), True) ################################################## # Connections ################################################## self.msg_connect((self.fullduplex_count_packets_0, 'out_msg'), (self.fullduplex_async_divide_0, 'in1')) self.msg_connect((self.fullduplex_count_packets_0_0, 'out_msg'), (self.fullduplex_async_divide_0, 'in2')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.fullduplex_count_packets_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fullduplex_packet_encap2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.fullduplex_packet_encap2_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_ofdm_tx_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.fullduplex_count_packets_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fullduplex_digital_sic_0_0, 1)) self.connect((self.digital_ofdm_rx_0_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.fullduplex_async_divide_0, 0), (self.qtgui_number_sink_0_0_0_0_0, 0)) self.connect((self.fullduplex_count_packets_0, 0), (self.blocks_null_sink_3_1_1, 1)) self.connect((self.fullduplex_count_packets_0_0, 0), (self.blocks_null_sink_3_1_1, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.blocks_complex_to_arg_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 2), (self.blocks_null_sink_3, 0)) self.connect((self.fullduplex_digital_sic_0_0, 0), (self.blocks_null_sink_3_1_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.digital_ofdm_rx_0_0_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.fullduplex_ofdm_constellation_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 0), (self.fullduplex_ofdm_constellation_0_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.fullduplex_snr_calc_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.fullduplex_digital_sic_0_0, 1), (self.qtgui_time_sink_x_0, 1)) self.connect((self.fullduplex_ofdm_constellation_0, 1), (self.blocks_null_sink_3_1, 1)) self.connect((self.fullduplex_ofdm_constellation_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fullduplex_ofdm_constellation_0_0, 1), (self.blocks_null_sink_3_1, 0)) self.connect((self.fullduplex_ofdm_constellation_0_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.fullduplex_digital_sic_0_0, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.uhd_usrp_sink, 0)) self.connect((self.fullduplex_packet_encap2_0_0, 0), (self.uhd_usrp_sink, 1)) self.connect((self.fullduplex_snr_calc_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.uhd_usrp_source, 1), (self.blocks_null_sink_1, 0)) self.connect((self.uhd_usrp_source, 0), (self.blocks_stream_to_tagged_stream_1, 0))
def __init__(self, amplitude1=0.1, amplitude2=0.1): gr.top_block.__init__(self, "Tx") ################################################## # Parameters ################################################## self.amplitude1 = amplitude1 self.amplitude2 = amplitude2 ################################################## # 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.fft_len = fft_len = 64 self.zcpu = zcpu = psutil self._txfreq_config = ConfigParser.ConfigParser() self._txfreq_config.read("./default") try: txfreq = self._txfreq_config.getfloat("usrp_hydra", "txfreq") except: txfreq = 2.484e9 self.txfreq = txfreq 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._samprate2_config = ConfigParser.ConfigParser() self._samprate2_config.read("./default") try: samprate2 = self._samprate2_config.getfloat("usrp_hydra", "samprate2") except: samprate2 = 200e3 self.samprate2 = samprate2 self._samprate1_config = ConfigParser.ConfigParser() self._samprate1_config.read("./default") try: samprate1 = self._samprate1_config.getfloat("usrp_hydra", "samprate1") except: samprate1 = 500e3 self.samprate1 = samprate1 self._samprate_config = ConfigParser.ConfigParser() self._samprate_config.read("./default") try: samprate = self._samprate_config.getfloat("usrp_hydra", "samprate") except: samprate = 2e6 self.samprate = samprate self.pilot_symbols = pilot_symbols = ((-1,1, 1, -1, -1, -1),) self.packet_len = packet_len = 100 self.occupied_carriers = occupied_carriers = (sorted(tuple(set([x for x in range(-26,27)]) - set(pilot_carriers[0]) - set([0,]))),) self.nbiot_tx_goodput = nbiot_tx_goodput = 0 self.nbiot_rate = nbiot_rate = 0 self.lte_tx_goodput = lte_tx_goodput = 0 self.lte_rate = lte_rate = 0 self._freq2_config = ConfigParser.ConfigParser() self._freq2_config.read("./default") try: freq2 = self._freq2_config.getfloat("usrp_hydra", "txfreq2") except: freq2 = 2.484e9+500e3 self.freq2 = freq2 self._freq1_config = ConfigParser.ConfigParser() self._freq1_config.read("./default") try: freq1 = self._freq1_config.getfloat("usrp_hydra", "txfreq1") except: freq1 = 2.484e9-500e3 self.freq1 = freq1 self.cpu_percent = cpu_percent = 0 ################################################## # Blocks ################################################## self.znbiotrate = blocks.probe_rate(gr.sizeof_char*1, 2000, 0.15) self.zlterate = blocks.probe_rate(gr.sizeof_char*1, 2000, 0.15) self.zznbiot_rate = blocks.probe_rate(gr.sizeof_gr_complex*1, 500.0, 0.15) self.zzlte_rate = blocks.probe_rate(gr.sizeof_gr_complex*1, 500.0, 0.15) self.xmlrpc_server_0_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 1235), allow_none=True) self.xmlrpc_server_0_0.register_instance(self) self.xmlrpc_server_0_0_thread = threading.Thread(target=self.xmlrpc_server_0_0.serve_forever) self.xmlrpc_server_0_0_thread.daemon = True self.xmlrpc_server_0_0_thread.start() self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samprate) self.uhd_usrp_sink_0.set_center_freq(txfreq, 0) self.uhd_usrp_sink_0.set_normalized_gain(0.9, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) def _nbiot_tx_goodput_probe(): while True: val = self.znbiotrate.rate() try: self.set_nbiot_tx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _nbiot_tx_goodput_thread = threading.Thread(target=_nbiot_tx_goodput_probe) _nbiot_tx_goodput_thread.daemon = True _nbiot_tx_goodput_thread.start() def _nbiot_rate_probe(): while True: val = self.zznbiot_rate.rate() try: self.set_nbiot_rate(val) except AttributeError: pass time.sleep(1.0 / (1)) _nbiot_rate_thread = threading.Thread(target=_nbiot_rate_probe) _nbiot_rate_thread.daemon = True _nbiot_rate_thread.start() def _lte_tx_goodput_probe(): while True: val = self.zlterate.rate() try: self.set_lte_tx_goodput(val) except AttributeError: pass time.sleep(1.0 / (10)) _lte_tx_goodput_thread = threading.Thread(target=_lte_tx_goodput_probe) _lte_tx_goodput_thread.daemon = True _lte_tx_goodput_thread.start() def _lte_rate_probe(): while True: val = self.zzlte_rate.rate() try: self.set_lte_rate(val) except AttributeError: pass time.sleep(1.0 / (1)) _lte_rate_thread = threading.Thread(target=_lte_rate_probe) _lte_rate_thread.daemon = True _lte_rate_thread.start() self.hydra_hydra_sink_0 = hydra.hydra_sink(2, 1024, txfreq, samprate, ((freq1, samprate1), (freq2, samprate2), )) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="length", bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=16, 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=1, rolloff=0, debug_log=False, scramble_bits=False ) 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_udp_source_1 = blocks.udp_source(gr.sizeof_gr_complex*1, "127.0.0.1", 8080, 1472, True) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char*1, "192.168.5.242", 22, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, "127.0.0.1", 6544, 1472, True) self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "length") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, "length") self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((amplitude2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amplitude1, )) self.analog_random_source_x_0_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 1000)), True) 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.analog_random_source_x_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.hydra_hydra_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.zzlte_rate, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.hydra_hydra_sink_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.zznbiot_rate, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.zlterate, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.znbiotrate, 0)) self.connect((self.blocks_udp_source_1, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_udp_source_1, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.hydra_hydra_sink_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Parameter Estimation") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Parameter Estimation") 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_parameter_estimation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.fft_len = fft_len = 256 self.cp_len = cp_len = 32 self.SNR = SNR = 15 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=((0.8, 0.01, 0.02, 0.01, 0.01, 0.08, 0.07)), fractional_bw=None, ) self.ofdm_param_estim_ofdm_param_estimation_c_0 = ofdm_param_estim.ofdm_param_estimation_c( samp_rate, 0, 7000, ([16, 32, 64, 128, 256, 512, 1024]), ([4, 8, 16, 32])) self.inspector_signal_detector_cvf_0 = inspector.signal_detector_cvf( samp_rate, 1024, firdes.WIN_BLACKMAN_hARRIS, -35, 0.2, False, 0.8, 0.0001, 1000, '') self.inspector_qtgui_sink_vf_0 = inspector.qtgui_inspector_sink_vf( samp_rate, 1024, 0, 1000, 1, True) self._inspector_qtgui_sink_vf_0_win = sip.wrapinstance( self.inspector_qtgui_sink_vf_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._inspector_qtgui_sink_vf_0_win) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=cp_len, packet_length_tag_key='length', occupied_carriers=(range(-128 / 2, 0) + range(1, 128 / 2), ), bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=numpy.sqrt(20000 * (10**(-SNR / 10.0))), frequency_offset=0.0, epsilon=0.8, taps=(numpy.random.rand(1, 10)[0] + 1j * numpy.random.rand(1, 10)[0]), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, 6400, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 50, 'length') self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 10000000)), True) ################################################## # Connections ################################################## self.msg_connect((self.inspector_signal_detector_cvf_0, 'map_out'), (self.inspector_qtgui_sink_vf_0, 'map_in')) self.msg_connect( (self.ofdm_param_estim_ofdm_param_estimation_c_0, 'ofdm_out'), (self.inspector_qtgui_sink_vf_0, 'analysis_in')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.inspector_signal_detector_cvf_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.ofdm_param_estim_ofdm_param_estimation_c_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.inspector_signal_detector_cvf_0, 0), (self.inspector_qtgui_sink_vf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM PU Phy") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM PU Phy") 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.samp_rate = samp_rate = 10e6 self.taps = taps = filter.firdes.low_pass(1, samp_rate, 0.95e6, 0.05e6) 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.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 64 self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.len_tag_key = len_tag_key = "packet_len" self.interp_factor = interp_factor = 5 self.fft_len = fft_len = 64 self.decim_factor = decim_factor = 1 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( "", 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(2.49e9, 0) #1255e6, 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna('J1', 0) self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=interp_factor, decimation=decim_factor, taps=(taps), fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_ofdm_tx_0_2 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0_1 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) # params: db_ip port scenario,ch1,ch2,gain(if static, if not leave it out or type -1) self.dbconnect_pktgen_0 = dbconnect.pktgen(1, packet_len, False, False, False, "127.0.0.1", 5003, 5, 10, 2, 20, 50, 100, 30000, 0.05, 6643, 5, 30, 2000, 2, 0, 3, -1, 5) self.dbconnect_pdu_fillpath_cpp_0_0_1 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0_0_0 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0_0 = dbconnect.pdu_fillpath_cpp() self.dbconnect_pdu_fillpath_cpp_0 = dbconnect.pdu_fillpath_cpp() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_3_1 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0_3_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0_3 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.18, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_add_xx_2 = blocks.add_vcc(1) self.analog_sig_source_x_0_3 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0) self.analog_sig_source_x_0_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_0, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0_0, 'in0')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_1, 'pdus'), (self.dbconnect_pdu_fillpath_cpp_0_0_1, 'in0')) self.msg_connect((self.dbconnect_pktgen_0, 'cmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out1'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out2'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'out3'), (self.blocks_pdu_to_tagged_stream_0_0_1, 'pdus')) self.msg_connect((self.dbconnect_pktgen_0, 'cmd'), (self.uhd_usrp_sink_0, 'command')) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1)) self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2)) self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.digital_ofdm_tx_0_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_1, 0), (self.digital_ofdm_tx_0_2, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0, 0), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_0, 0), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_1, 0), (self.rational_resampler_xxx_0_0_1_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_3, 0)) self.connect((self.digital_ofdm_tx_0_1, 0), (self.blocks_tagged_stream_to_pdu_0_3_0, 0)) self.connect((self.digital_ofdm_tx_0_2, 0), (self.blocks_tagged_stream_to_pdu_0_3_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm00") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm00") 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", "ofdm00") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.packet_len = packet_len = 50 self.len_tag_key = len_tag_key = "packet_len" self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI 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(-80, 10) 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.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*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, len_tag_key) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0))
def __init__(self): gr.top_block.__init__(self, "Example5 Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Example5 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", "example5_tx") 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)) ################################################## # Variables ################################################## self.time_preamble = time_preamble = [ 0.125000 + 0.000000j, 0.522104 - 0.148216j, -0.495528 + 0.114832j, -0.267916 + 0.091700j, 0.236544 - 0.138456j, -0.098500 + 0.473800j, 0.476480 - 0.225344j, -0.187516 + 0.035372j, 0.051776 - 0.353552j, -0.104936 + 0.059916j, 0.228684 + 0.117504j, -0.530912 + 0.560756j, 0.359128 + 0.015872j, -0.132852 + 0.632840j, -0.105164 - 0.368872j, 0.368272 - 0.032412j, 0.125000 + 0.750000j, 0.463968 + 0.457792j, 0.151476 - 0.430948j, 0.685052 + 0.238524j, 0.494428 + 0.119428j, -0.557540 - 0.050056j, 0.416348 + 0.017368j, 0.104256 - 0.568836j, -0.301776 - 0.353552j, 0.079812 + 0.451516j, 0.439152 + 0.528072j, 0.642060 + 0.178484j, -0.090096 + 0.465096j, -0.446492 + 0.305776j, -0.111440 - 0.093688j, -0.538848 - 0.320228j, 0.125000 + 0.000000j, -0.538848 + 0.320228j, -0.111440 + 0.093688j, -0.446492 - 0.305776j, -0.090096 - 0.465096j, 0.642060 - 0.178484j, 0.439152 - 0.528072j, 0.079812 - 0.451516j, -0.301776 + 0.353552j, 0.104256 + 0.568836j, 0.416348 - 0.017368j, -0.557540 + 0.050056j, 0.494428 - 0.119428j, 0.685052 - 0.238524j, 0.151476 + 0.430948j, 0.463968 - 0.457792j, 0.125000 - 0.750000j, 0.368272 + 0.032412j, -0.105164 + 0.368872j, -0.132852 - 0.632840j, 0.359128 - 0.015872j, -0.530912 - 0.560756j, 0.228684 - 0.117504j, -0.104936 - 0.059916j, 0.051776 + 0.353552j, -0.187516 - 0.035372j, 0.476480 + 0.225344j, -0.098500 - 0.473800j, 0.236544 + 0.138456j, -0.267916 - 0.091700j, -0.495528 - 0.114832j, 0.522104 + 0.148216j ] self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 500000 self.preamble_len = preamble_len = 64 self.packet_len = packet_len = 1024 self.noise = noise = 0 self.length = length = 96 self.freq_offset = freq_offset = 0 ################################################## # Blocks ################################################## self._time_offset_range = Range(0.999, 1.001, 0.00001, 1, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 2, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 3)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._noise_range = Range(0, 0.2, 0.001, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 2) [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, 2)] self._freq_offset_range = Range(0, 0.02, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win, 1, 0, 1, 2) [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, 2)] self.qtgui_freq_sink_x_0_0_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Real Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_0.set_y_axis(-80, -20) self.qtgui_freq_sink_x_0_0_0_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0_0.set_plot_pos_half(not True) labels = ['MySVL Signal', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_win, 3, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(3, 4)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self.mysvl_svl_1 = mysvl.svl( gr.sizeof_gr_complex * 1, 1, './inputs/spectrum_maps/example1b_tx.txt', './inputs/parameters/example1a-c_tx.txt') self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf( 2, firdes.low_pass(1, samp_rate, samp_rate / 4 - samp_rate / 32, samp_rate / 32, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, samp_rate / 2 - samp_rate / 32, samp_rate / 32, firdes.WIN_HAMMING, 6.76)) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key='length', bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1 + 1j, ), noise_seed=0, block_tags=False) self.blocks_vector_source_x_0 = blocks.vector_source_c( time_preamble, True, 1, []) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', 4000, 1472 * 32, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_0 = blocks.stream_mux( gr.sizeof_gr_complex * 1, (preamble_len, packet_len)) self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((0.1, )) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (2.0 / 4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, './inputs/Memory_and_Forgetting.mp3', True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, './inputs/Memory_and_Forgetting.mp3', True) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_1, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blks2_packet_encoder_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0_0_0_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.mysvl_svl_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.mysvl_svl_1, 1)) self.connect((self.mysvl_svl_1, 0), (self.blocks_stream_mux_0, 1))
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.sync_word_zeros = sync_word_zeros = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.sync_word = sync_word = [ 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.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.packet_len = packet_len = 80 - 48 self.occupied_carriers_len = occupied_carriers_len = len( occupied_carriers[0]) self.variable_function_probe_0_2 = variable_function_probe_0_2 = 0 self.variable_function_probe_0_1_0 = variable_function_probe_0_1_0 = 0 self.variable_function_probe_0_0_1 = variable_function_probe_0_0_1 = 0 self.variable_function_probe_0_0_0_0 = variable_function_probe_0_0_0_0 = 0 self.usrp_source_addr = usrp_source_addr = "addr0=192.168.30.4" self.usrp_sink_addr = usrp_sink_addr = "addr0=192.168.30.4" self.sync_word_zero_len = sync_word_zero_len = len(sync_word_zeros) self.sync_word_len = sync_word_len = len(sync_word) 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.symbols_num = symbols_num = ( packet_len + 4) * 8 / 2 / occupied_carriers_len + 3 self.samp_rate = samp_rate = 1e6 self.qf_1 = qf_1 = 0 self.qf_0 = qf_0 = 0 self.pilot_symbols_len = pilot_symbols_len = len(pilot_symbols[0]) self.pilot_carriers_len = pilot_carriers_len = len(pilot_carriers[0]) self.pad_tail_len = pad_tail_len = 1000 self.pad_front_len = pad_front_len = 20000 * 2 self.out_buf_size = out_buf_size = 96000 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 950e6 self.frame_len = frame_len = ( (packet_len + 4) / 12 + 3 + 2 + 2 + 2 * 2) * 80 self.fft_len = fft_len = 64 self.delay_tx2rx = delay_tx2rx = 50 self.dac_2 = dac_2 = 0 self.dac_1 = dac_1 = 0 self.dac_0 = dac_0 = 0 self.cf_1 = cf_1 = 0 self.cf_0 = cf_0 = 0 self.cap_2 = cap_2 = 0 self.cap_1 = cap_1 = 0 self.cap_0 = cap_0 = 0 self.canc_path = canc_path = 0 self.att_2 = att_2 = 0 self.att_1 = att_1 = 0 self.att_0 = att_0 = 0 ################################################## # Blocks ################################################## self.uhd_usrp_source = uhd.usrp_source( ",".join((usrp_source_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source.set_samp_rate(samp_rate) self.uhd_usrp_source.set_center_freq(freq, 0) self.uhd_usrp_source.set_gain(15, 0) self.uhd_usrp_source.set_antenna('RX2', 0) self.uhd_usrp_source.set_auto_dc_offset(True, 0) self.uhd_usrp_source.set_auto_iq_balance(True, 0) self.uhd_usrp_sink = uhd.usrp_sink( ",".join((usrp_sink_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink.set_samp_rate(samp_rate) self.uhd_usrp_sink.set_center_freq(freq, 0) self.uhd_usrp_sink.set_gain(0, 0) self.uhd_usrp_sink.set_antenna('TX/RX', 0) self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Rx Packets') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Rx Signal Spectr') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Estimated Digital Taps') self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, 'Sync b/w Two Radios') self.tab_widget_4 = Qt.QWidget() self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_4) self.tab_grid_layout_4 = Qt.QGridLayout() self.tab_layout_4.addLayout(self.tab_grid_layout_4) self.tab.addTab(self.tab_widget_4, 'SI Channel') self.top_grid_layout.addWidget(self.tab, 0, 0, 1, 3) self._delay_tx2rx_range = Range(0, 100, 1, 50, 200) self._delay_tx2rx_win = RangeWidget(self._delay_tx2rx_range, self.set_delay_tx2rx, "delay_tx2rx", "counter_slider", int) self.top_grid_layout.addWidget(self._delay_tx2rx_win, 7, 0, 1, 3) def _variable_function_probe_0_2_probe(): while True: val = self.uhd_usrp_sink.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_2(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_2_thread = threading.Thread( target=_variable_function_probe_0_2_probe) _variable_function_probe_0_2_thread.daemon = True _variable_function_probe_0_2_thread.start() def _variable_function_probe_0_1_0_probe(): while True: val = self.uhd_usrp_source.set_time_now(uhd.time_spec_t(0.0)) try: self.set_variable_function_probe_0_1_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_1_0_thread = threading.Thread( target=_variable_function_probe_0_1_0_probe) _variable_function_probe_0_1_0_thread.daemon = True _variable_function_probe_0_1_0_thread.start() def _variable_function_probe_0_0_1_probe(): while True: val = self.uhd_usrp_sink.set_start_time(uhd.time_spec_t(1.0)) try: self.set_variable_function_probe_0_0_1(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_1_thread = threading.Thread( target=_variable_function_probe_0_0_1_probe) _variable_function_probe_0_0_1_thread.daemon = True _variable_function_probe_0_0_1_thread.start() def _variable_function_probe_0_0_0_0_probe(): while True: val = self.uhd_usrp_source.set_start_time(uhd.time_spec_t(1.0)) try: self.set_variable_function_probe_0_0_0_0(val) except AttributeError: pass time.sleep(1.0 / (1e-9)) _variable_function_probe_0_0_0_0_thread = threading.Thread( target=_variable_function_probe_0_0_0_0_probe) _variable_function_probe_0_0_0_0_thread.daemon = True _variable_function_probe_0_0_0_0_thread.start() self.sub20fde_fde_config_0 = sub20fde.fde_config(0, 0, '5647') self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 21 * 1, #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_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_len") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(True) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = [ "Digital Canc. Tap - I", "Digital Canc. Tap - Q", '', '', '', '', '', '', '', '' ] widths = [2, 2, 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 = [0, 0, -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_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.tab_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0_0_1 = qtgui.time_sink_c( 80, #size samp_rate, #samp_rate 'Scope Plot', #name 2 #number of inputs ) self.qtgui_time_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_len") self.qtgui_time_sink_x_0_0_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_1.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0_0_0_1.disable_legend() labels = [ "SI after Circ. + RF Canc. - I", "SI after Circ. + RF Canc. - Q", "SI after Circ. + RF Canc. + Digital Canc. - I", "SI after Circ. + RF Canc. + Digital Canc. - Q", '', '', '', '', '', '' ] widths = [2, 2, 2, 2, 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(4): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.tab_layout_3.addWidget(self._qtgui_time_sink_x_0_0_0_1_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c( frame_len, #size samp_rate, #samp_rate 'Scope Plot', #name 2 #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) 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, "packet_len") 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(True) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = [ "SI after Circ. + RF Canc. - I", "SI after Circ. + RF Canc. - Q", "SI after Circ. + RF Canc. + Digital Canc. - I", "SI after Circ. + RF Canc. + Digital Canc. - Q", '', '', '', '', '', '' ] widths = [2, 2, 2, 2, 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(4): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.tab_layout_0.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 64, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_4.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024 * 3, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-120, 0) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(True) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = [ "SI after Circ. + RF Canc.", "SI after Circ. + RF + Digital Canc.", '', '', '', '', '', '', '', '' ] widths = [2, 2, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_1_win) self._qf_1_range = Range(0, 31, 1, 0, 200) self._qf_1_win = RangeWidget(self._qf_1_range, self.set_qf_1, "qf_1", "counter_slider", int) self.top_grid_layout.addWidget(self._qf_1_win, 3, 1, 1, 1) self._qf_0_range = Range(0, 31, 1, 0, 200) self._qf_0_win = RangeWidget(self._qf_0_range, self.set_qf_0, "qf_0", "counter_slider", int) self.top_grid_layout.addWidget(self._qf_0_win, 3, 0, 1, 1) self.fullduplex_parse_stream_sync_1 = fullduplex.parse_stream_sync( False, delay_tx2rx, pad_front_len, 320) (self.fullduplex_parse_stream_sync_1).set_min_output_buffer(96000) self.fullduplex_packet_encap2_0 = fullduplex.packet_encap2( False, False, 0.001, pad_front_len, pad_tail_len, 0) (self.fullduplex_packet_encap2_0).set_min_output_buffer(96000) self.fullduplex_digital_sic_0 = fullduplex.digital_sic( False, delay_tx2rx, pad_front_len, 0, frame_len, 10, 1) (self.fullduplex_digital_sic_0).set_min_output_buffer(96000) self.fft_vxx_0_0 = fft.fft_vcc(64, True, (window.blackmanharris(64)), True, 1) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.blackmanharris(64)), True, 1) self.digital_ofdm_tx_0_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, 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, rolloff=0, debug_log=False, scramble_bits=False) self._dac_2_range = Range(0, 255, 1, 0, 200) self._dac_2_win = RangeWidget(self._dac_2_range, self.set_dac_2, "dac_2", "counter_slider", int) self.top_grid_layout.addWidget(self._dac_2_win, 5, 2, 1, 1) self._dac_1_range = Range(0, 255, 1, 0, 200) self._dac_1_win = RangeWidget(self._dac_1_range, self.set_dac_1, "dac_1", "counter_slider", int) self.top_grid_layout.addWidget(self._dac_1_win, 5, 1, 1, 1) self._dac_0_range = Range(0, 255, 1, 0, 200) self._dac_0_win = RangeWidget(self._dac_0_range, self.set_dac_0, "dac_0", "counter_slider", int) self.top_grid_layout.addWidget(self._dac_0_win, 5, 0, 1, 1) self._cf_1_range = Range(0, 15, 1, 0, 200) self._cf_1_win = RangeWidget(self._cf_1_range, self.set_cf_1, "cf_1", "counter_slider", int) self.top_grid_layout.addWidget(self._cf_1_win, 2, 1, 1, 1) self._cf_0_range = Range(0, 15, 1, 0, 200) self._cf_0_win = RangeWidget(self._cf_0_range, self.set_cf_0, "cf_0", "counter_slider", int) self.top_grid_layout.addWidget(self._cf_0_win, 2, 0, 1, 1) self._cap_2_range = Range(0, 15, 1, 0, 200) self._cap_2_win = RangeWidget(self._cap_2_range, self.set_cap_2, "cap_2", "counter_slider", int) self.top_grid_layout.addWidget(self._cap_2_win, 1, 2, 1, 1) self._cap_1_range = Range(0, 15, 1, 0, 200) self._cap_1_win = RangeWidget(self._cap_1_range, self.set_cap_1, "cap_1", "counter_slider", int) self.top_grid_layout.addWidget(self._cap_1_win, 1, 1, 1, 1) self._cap_0_range = Range(0, 15, 1, 0, 200) self._cap_0_win = RangeWidget(self._cap_0_range, self.set_cap_0, "cap_0", "counter_slider", int) self.top_grid_layout.addWidget(self._cap_0_win, 1, 0, 1, 1) self._canc_path_range = Range(0, 1, 1, 0, 200) self._canc_path_win = RangeWidget(self._canc_path_range, self.set_canc_path, "canc_path", "counter_slider", int) self.top_grid_layout.addWidget(self._canc_path_win, 6, 0, 1, 3) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 64) self.blocks_vector_source_x_0 = blocks.vector_source_b( range(50), True, 1, ()) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, frame_len + pad_front_len + pad_tail_len, "packet_len") (self.blocks_stream_to_tagged_stream_1).set_min_output_buffer(96000) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, "packet_len") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (0.01 * 2.23 * 0.56 * 1.4 * 1.4, )) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_magphase_0 = blocks.complex_to_magphase(1) self._att_2_range = Range(0, 127, 1, 0, 200) self._att_2_win = RangeWidget(self._att_2_range, self.set_att_2, "att_2", "counter_slider", int) self.top_grid_layout.addWidget(self._att_2_win, 4, 2, 1, 1) self._att_1_range = Range(0, 127, 1, 0, 200) self._att_1_win = RangeWidget(self._att_1_range, self.set_att_1, "att_1", "counter_slider", int) self.top_grid_layout.addWidget(self._att_1_win, 4, 1, 1, 1) self._att_0_range = Range(0, 127, 1, 0, 200) self._att_0_win = RangeWidget(self._att_0_range, self.set_att_0, "att_0", "counter_slider", int) self.top_grid_layout.addWidget(self._att_0_win, 4, 0, 1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_magphase_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_complex_to_magphase_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_complex_to_magphase_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fullduplex_packet_encap2_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fullduplex_digital_sic_0, 1)) self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self.fullduplex_parse_stream_sync_1, 1)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.digital_ofdm_tx_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.fullduplex_digital_sic_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.fullduplex_digital_sic_0, 1), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.fullduplex_digital_sic_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.fullduplex_digital_sic_0, 1), (self.qtgui_time_sink_x_0_0_0, 1)) self.connect((self.fullduplex_digital_sic_0, 2), (self.qtgui_time_sink_x_1, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.fullduplex_digital_sic_0, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.fullduplex_parse_stream_sync_1, 0)) self.connect((self.fullduplex_packet_encap2_0, 0), (self.uhd_usrp_sink, 0)) self.connect((self.fullduplex_parse_stream_sync_1, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.fullduplex_parse_stream_sync_1, 1), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.fullduplex_parse_stream_sync_1, 0), (self.qtgui_time_sink_x_0_0_0_1, 0)) self.connect((self.fullduplex_parse_stream_sync_1, 1), (self.qtgui_time_sink_x_0_0_0_1, 1)) self.connect((self.uhd_usrp_source, 0), (self.blocks_stream_to_tagged_stream_1, 0))
def __init__(self): gr.top_block.__init__( self, "OFDM in the presence of fast fading, channel and hardware impairments" ) Qt.QWidget.__init__(self) self.setWindowTitle( "OFDM in the presence of fast fading, channel and hardware impairments" ) 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_simulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.vec_length = vec_length = 1 self.update_period = update_period = 0.10 self.timing = timing = 1.0001 self.samp_rate = samp_rate = 7.68e6 self.q_offset = q_offset = 0 self.phase_noise = phase_noise = 0 self.packet_len = packet_len = 50 self.num_of_points = num_of_points = 1024 self.noise = noise = 1.2 self.len_tag_key = len_tag_key = "packet_len" self.iq_ph = iq_ph = 0 self.iq_mag = iq_mag = 0 self.i_offset = i_offset = 0 self.freq = freq = 0.01 self.fft_len = fft_len = 128 self.dist3 = dist3 = 0 self.dist2 = dist2 = 0 self.cfo_std = cfo_std = 0.01 ################################################## # Blocks ################################################## self._timing_range = Range(0.999, 1.001, 0.0001, 1.0001, 200) self._timing_win = RangeWidget(self._timing_range, self.set_timing, 'Timing Offset', "slider", float) self.top_grid_layout.addWidget(self._timing_win, 0, 2, 1, 1) self._q_offset_range = Range(-1, 1, 0.01, 0, 200) self._q_offset_win = RangeWidget(self._q_offset_range, self.set_q_offset, 'Quadrature Offset', "slider", float) self.top_grid_layout.addWidget(self._q_offset_win, 1, 3, 1, 1) self._phase_noise_range = Range(0, 40, 0.5, 0, 200) self._phase_noise_win = RangeWidget(self._phase_noise_range, self.set_phase_noise, 'Phase Noise', "slider", float) self.top_grid_layout.addWidget(self._phase_noise_win, 0, 3, 1, 1) self._noise_range = Range(0, 2, 0.01, 1.2, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Voltage', "slider", float) self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 1) self._iq_ph_range = Range(-3.14, 3.14, 0.01, 0, 200) self._iq_ph_win = RangeWidget(self._iq_ph_range, self.set_iq_ph, 'IQ Phase Imbalance', "slider", float) self.top_grid_layout.addWidget(self._iq_ph_win, 1, 1, 1, 1) self._iq_mag_range = Range(0, 1, 0.01, 0, 200) self._iq_mag_win = RangeWidget(self._iq_mag_range, self.set_iq_mag, 'IQ Mag. Imbalance', "slider", float) self.top_grid_layout.addWidget(self._iq_mag_win, 1, 0, 1, 1) self._i_offset_range = Range(-1, 1, 0.01, 0, 200) self._i_offset_win = RangeWidget(self._i_offset_range, self.set_i_offset, 'Inphase Offset', "slider", float) self.top_grid_layout.addWidget(self._i_offset_win, 1, 2, 1, 1) self._freq_range = Range(-1, 1, 0.01, 0.01, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency Offset', "slider", float) self.top_grid_layout.addWidget(self._freq_win, 0, 1, 1, 1) self._dist3_range = Range(0, 0.1, 0.0001, 0, 200) self._dist3_win = RangeWidget(self._dist3_range, self.set_dist3, 'Third Order Dist', "slider", float) self.top_grid_layout.addWidget(self._dist3_win, 2, 1, 1, 1) self._dist2_range = Range(0, 0.1, 0.0001, 0, 200) self._dist2_win = RangeWidget(self._dist2_range, self.set_dist2, '2nd Order Dist.', "slider", float) self.top_grid_layout.addWidget(self._dist2_win, 2, 0, 1, 1) self._cfo_std_range = Range(0, 0.1, 0.01, 0.01, 200) self._cfo_std_win = RangeWidget(self._cfo_std_range, self.set_cfo_std, 'CFO standart deviation ', "slider", float) self.top_grid_layout.addWidget(self._cfo_std_win, 2, 2, 1, 1) self.qtgui_waterfall_sink_x_1_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "GT GUI Waterfall Sink- TX Output", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_1_0.enable_grid(False) self.qtgui_waterfall_sink_x_1_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_1_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_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_0_win, 4, 2, 1, 1) self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "GT GUI Waterfall Sink-TX Output", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1.set_update_time(0.10) self.qtgui_waterfall_sink_x_1.enable_grid(False) self.qtgui_waterfall_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_win, 3, 3, 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'QT GUI Waterfall Sink - RX RF front-end output', #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['Rx', '', '', '', '', '', '', '', '', ''] colors = [3, 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, 5, 2, 1, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( num_of_points, #size samp_rate, #samp_rate 'Random source output', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(update_period) self.qtgui_time_sink_x_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_1.set_y_label("", "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_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_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_1_win, 3, 0, 1, 1) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "QT GUI Time Sink - RX RF front-end output", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_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_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 6, 0, 1, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI Time Sink - RX RF front-end output", #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) 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(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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, 5, 0, 1, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI Time Sink - Channel output", #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(-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(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) 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(2 * 1): 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, 4, 0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( num_of_points, #size samp_rate, #samp_rate "QT GUI Time Sink - TX output", #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 = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 3, 1, 1, 1) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 0) 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(True) 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, 6, 1, 1, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Frequency Sink - TX Output", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(False) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 4, 1, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Frequency Sink - TX Output", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 3, 2, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'QT GUI Frequenx=cy Sink - RX RF front-end output', #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(-80, 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 = ['Rx', '', '', '', '', '', '', '', '', ''] 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, 5, 1, 1, 1) self.fec_ber_bf_0 = fec.ber_bf(False, 100, -7.0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len / 4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len / 4, frame_length_tag_key='frame_' + "rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.channels_impairments_0 = channels.impairments( phase_noise, iq_mag, iq_ph, q_offset, i_offset, 0, dist2, dist3) self.channels_dynamic_channel_model_0 = channels.dynamic_channel_model( samp_rate, 0.01, 1e3, cfo_std, 1e3, 8, 2.0, False, 4.0, (-0.0025, -0.00125, 0.0, 0.00125, 0.0025, 0.00375, 0.005, 0.00625, 0.0075, 0.00875, 0.01, 0.01125, 0.0125, 0.015, 0.01625, 0.0175, 0.01875, 0.02, 0.02125, 0.0225, 0.02375, 0.025, 0.0275, 0.02875, 0.03, 0.03125, 0.0325, 0.03375, 0.035, 0.03625, 0.0375, 0.03875, 0.04, 0.04125, 0.0425, 0.04375, 0.045, 0.04625, 0.0475, 0.05125, 0.0525, 0.055, 0.05625, 0.0575, 0.06, 0.06375, 0.065, 0.06625, 0.0675, 0.06875, 0.0725, 0.08, 0.08125, 0.085, 0.08625, 0.0875, 0.08875, 0.09125, 0.0925, 0.09375, 0.095, 0.09875, 0.1, 0.1075, 0.10875, 0.11, 0.11125, 0.13125, 0.1325), (0.16529889, 0.46954084, 0.58274825, 0.24561255, 0.50459457, 0.69767633, 1.0, 0.77724474, 0.48675226, 0.46954084, 0.21267289, 0.19090106, 0.31600413, 0.45293801, 0.8057353, 0.64920938, 0.50459457, 0.1978987, 0.35204369, 0.54226525, 0.31600413, 0.15945397, 0.2204686, 0.35204369, 0.37832563, 0.37832563, 0.36494815, 0.2204686, 0.17763933, 0.45293801, 0.52309091, 0.52309091, 0.46954084, 0.35204369, 0.40656966, 0.25461568, 0.23692776, 0.32758753, 0.1978987, 0.21267289, 0.2204686, 0.19090106, 0.24561255, 0.17135806, 0.21267289, 0.16529889, 0.2204686, 0.30483032, 0.33959553, 0.18415085, 0.18415085, 0.22855006, 0.2940516, 0.19090106, 0.17135806, 0.18415085, 0.1978987, 0.17763933, 0.15945397, 0.26394884, 0.24561255, 0.21267289, 0.19090106, 0.17763933, 0.2204686, 0.21267289, 0.17135806, 0.17135806, 0.16529889), 8, 1.0, 0) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq, epsilon=timing, taps=(1.0, ), noise_seed=0, block_tags=False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, '', 'packet_num') self.blocks_tag_debug_0.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, vec_length, packet_len, len_tag_key) self.blocks_ctrlport_monitor_performance_0 = not True or monitor( "gr-perf-monitorx") self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.fec_ber_bf_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_dynamic_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.channels_impairments_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_waterfall_sink_x_1_0, 0)) self.connect((self.channels_dynamic_channel_model_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_impairments_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.channels_impairments_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_impairments_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.channels_impairments_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_char_to_float_0_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.fec_ber_bf_0, 1)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_waterfall_sink_x_1, 0)) self.connect((self.fec_ber_bf_0, 0), (self.qtgui_number_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Example1") Qt.QWidget.__init__(self) self.setWindowTitle("Example1") 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", "example1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000000 self.length = length = 96 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Demodulated GMSK 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_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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["Bytes", "", "", "", "", "", "", "", "", ""] 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, 2, 0, 1, 2) self.qtgui_freq_sink_x_0_0_0_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Virtual Spectrum 2", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_1.set_y_axis(-80, -20) self.qtgui_freq_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_1.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0_1.set_plot_pos_half(not True) labels = ["GMSK Signal", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_1_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0_0_0_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Real Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0_0.set_y_axis(-80, -20) self.qtgui_freq_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0_0.set_plot_pos_half(not True) labels = ["MySVL Signal", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_0_win, 1, 0, 1, 2) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Virtual Spectrum 1", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-80, -20) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not True) labels = ["OFDM Signal", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 0, 0, 1, 1) self.mysvl_svl_1 = mysvl.svl( gr.sizeof_gr_complex * 1, 1, "./inputs/spectrum_maps/example1a_tx.txt", "./inputs/parameters/example1a-c_tx.txt") self.mysvl_svl_0_0 = mysvl.svl( gr.sizeof_gr_complex * 1, 1, "./inputs/spectrum_maps/example1a_rx.txt", "./inputs/parameters/example1a-c_rx.txt") self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="length", bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=16, frame_length_tag_key='frame_' + "length", packet_length_tag_key="length", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, length, "length") self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc( (2.0 / 4, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, "./inputs/Memory_and_Forgetting.mp3", True) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, "./inputs/Memory_and_Forgetting.mp3", True) self.blocks_file_sink_0_0 = blocks.file_sink( gr.sizeof_char * 1, "./outputs/output_audio1.mp3", False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, "./outputs/output_audio2.mp3", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=0, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blks2_packet_encoder_1, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blks2_packet_encoder_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.mysvl_svl_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.mysvl_svl_1, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_freq_sink_x_0_0_0_1, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.mysvl_svl_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0_0_0_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.mysvl_svl_0_0, 1), (self.digital_gmsk_demod_0, 0)) self.connect((self.mysvl_svl_0_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.mysvl_svl_1, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm02") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm02") 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", "ofdm02") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.timing = timing = 1.0001 self.samp_rate = samp_rate = 100000 self.packet_len = packet_len = 50 self.noise = noise = 0.01 self.len_tag_key = len_tag_key = "packet_len" self.freq = freq = 0.01 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self._timing_layout = Qt.QVBoxLayout() self._timing_tool_bar = Qt.QToolBar(self) self._timing_layout.addWidget(self._timing_tool_bar) self._timing_tool_bar.addWidget(Qt.QLabel("Timing Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._timing_counter = qwt_counter_pyslot() self._timing_counter.setRange(0.999, 1.001, 0.0001) self._timing_counter.setNumButtons(2) self._timing_counter.setValue(self.timing) self._timing_tool_bar.addWidget(self._timing_counter) self._timing_counter.valueChanged.connect(self.set_timing) self._timing_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._timing_slider.setRange(0.999, 1.001, 0.0001) self._timing_slider.setValue(self.timing) self._timing_slider.setMinimumWidth(200) self._timing_slider.valueChanged.connect(self.set_timing) self._timing_layout.addWidget(self._timing_slider) self.top_grid_layout.addLayout(self._timing_layout, 2,0,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_tool_bar = Qt.QToolBar(self) self._noise_layout.addWidget(self._noise_tool_bar) self._noise_tool_bar.addWidget(Qt.QLabel("Noise Voltage"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._noise_counter = qwt_counter_pyslot() self._noise_counter.setRange(0, 3, 0.01) self._noise_counter.setNumButtons(2) self._noise_counter.setValue(self.noise) self._noise_tool_bar.addWidget(self._noise_counter) self._noise_counter.valueChanged.connect(self.set_noise) self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 3, 0.01) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 1,0,1,1) self._freq_layout = Qt.QVBoxLayout() self._freq_tool_bar = Qt.QToolBar(self) self._freq_layout.addWidget(self._freq_tool_bar) self._freq_tool_bar.addWidget(Qt.QLabel("Frequency Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_counter = qwt_counter_pyslot() self._freq_counter.setRange(-1, 1, 0.01) self._freq_counter.setNumButtons(2) self._freq_counter.setValue(self.freq) self._freq_tool_bar.addWidget(self._freq_counter) self._freq_counter.valueChanged.connect(self.set_freq) self._freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_slider.setRange(-1, 1, 0.01) self._freq_slider.setValue(self.freq) self._freq_slider.setMinimumWidth(200) self._freq_slider.valueChanged.connect(self.set_freq) self._freq_layout.addWidget(self._freq_slider) self.top_grid_layout.addLayout(self._freq_layout, 1,1,1,1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.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, 0,1,1,1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "QT GUI 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(-80, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0,0,1,1) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=fft_len, cp_len=fft_len/4, frame_length_tag_key='frame_'+"rx_len", packet_length_tag_key="rx_len", bps_header=1, bps_payload=2, debug_log=False, scramble_bits=False ) self.channels_fading_model_0 = channels.fading_model( 8, 10.0/samp_rate, False, 4.0, 0 ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq, epsilon=timing, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*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, len_tag_key) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_fading_model_0, 0)) self.connect((self.channels_fading_model_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tag_debug_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Tx") 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") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.packet_len = packet_len = 100 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(400e6, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True ) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(packet_len, 0xAA)), 1000) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0)) self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
def __init__(self): gr.top_block.__init__(self, "Ofdm Tx Doesntwork") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Tx Doesntwork") 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_doesntwork") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.packet_len = packet_len = 100 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "QT GUI 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.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_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True ) self.blocks_vector_source_x_0 = blocks.vector_source_b(range(packet_len), True, 1, ()) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, len_tag_key) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))