def test_003_channel_no_carroffset (self): """ Add a channel, check if it's correctly estimated """ fft_len = 16 carr_offset = 0 sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0) data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = sync_symbol1 + sync_symbol2 + data_symbol channel = (0, 0, 0, 2, -2, 2, 3j, 2, 0, 2, 2, 2, 2, 3, 0, 0) src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) sink = blocks.vector_sink_c(fft_len) sink_chanest = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.connect((chanest, 1), sink_chanest) self.tb.run() tags = sink.tags() self.assertEqual(shift_tuple(sink.data(), -carr_offset), tuple(numpy.multiply(data_symbol, channel))) for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': self.assertEqual(pmt.to_long(tag.value), carr_offset) if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': self.assertEqual(pmt.c32vector_elements(tag.value), channel) self.assertEqual(sink_chanest.data(), channel)
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.sps = sps = 8 self.fm_sensitivity = fm_sensitivity = 1.0 self.center_freq = center_freq = 2400e6 ################################################## # Blocks ################################################## 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(sps*1000000) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(70, 0) self.uhd_usrp_sink_0.set_bandwidth(1e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=fm_sensitivity, bt=0.32, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "sync3", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, command): gr.top_block.__init__(self, "Top Block") # ################################################## # # Variables # ################################################## self.samp_rate = samp_rate = 5e6 self.frequency = frequency = 49000000 self.command = command # ################################################## # # Blocks # ############################################### self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(frequency, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(47, 0) self.osmosdr_sink_0.set_bb_gain(16, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((6, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/cssummer2016/Desktop/" + self.command, True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))
def test_004_channel_no_carroffset_1sym (self): """ Add a channel, check if it's correctly estimated. Only uses 1 synchronisation symbol. """ fft_len = 16 carr_offset = 0 sync_symbol = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) tx_data = sync_symbol + data_symbol channel = (0, 0, 0, 2, 2, 2, 2, 3, 3, 2.5, 2.5, -3, -3, 1j, 1j, 0) #channel = (0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0) src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol, (), 1) sink = blocks.vector_sink_c(fft_len) sink_chanest = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.connect((chanest, 1), sink_chanest) self.tb.run() self.assertEqual(sink_chanest.data(), channel) tags = sink.tags() for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': self.assertEqual(pmt.to_long(tag.value), carr_offset) if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': self.assertEqual(pmt.c32vector_elements(tag.value), channel)
def __init__(self, serverip, serverport, clientname, packetsize, simulation, samp_rate, center_freq, net_id, device_addr, stream_args): gr.hier_block2.__init__(self, "sim_source_c", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) uhd_gate.__init__(self) self.simulation = simulation self.serverip = serverip self.samp_rate = samp_rate self.typ = 'rx' if not self.simulation: self.usrp = uhd.usrp_source(device_addr, stream_args) # TODO: Parameters self.connect(self.usrp, self) else: self.simsrc = sim_source_cc(self, serverip, serverport, clientname, packetsize, samp_rate, center_freq, net_id) # TODO: dirty hack!!! # self.tcp_source = grc_blks2.tcp_source(itemsize=gr.sizeof_gr_complex, # addr=self.serverip, # port=self.simsrc.get_dataport(), # server=False) self.tcp_source = gr.udp_source(itemsize=gr.sizeof_gr_complex, host=self.serverip, port=self.simsrc.get_dataport(), payload_size=1472, eof=False, wait=True) self.gain_blk = blocks.multiply_const_vcc((1, )) self.connect(self.tcp_source, self.gain_blk, self.simsrc, self)
def test_006_channel_and_carroffset (self): """ Add a channel, check if it's correctly estimated """ fft_len = 16 carr_offset = 2 # Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 sync_symbol1 = (0, 0, 0, 1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, 0) sync_symbol2 = (0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1, 0, 0) data_symbol = (0, 0, 0, 1, -1, 1, -1, 1, 0, 1, -1, -1, -1, 1, 0, 0) # Channel 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # Shifted (0, 0, 0, 0, 0, 1j, -1, 1, -1j, 1j, 0, 1, -1j, -1, -1j, 1) chanest_exp = (0, 0, 0, 5, 6, 7, 8, 9, 0, 11, 12, 13, 14, 15, 0, 0) tx_data = shift_tuple(sync_symbol1, carr_offset) + \ shift_tuple(sync_symbol2, carr_offset) + \ shift_tuple(data_symbol, carr_offset) channel = range(fft_len) src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) chanest = digital.ofdm_chanest_vcvc(sync_symbol1, sync_symbol2, 1) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, chan, chanest, sink) self.tb.run() tags = sink.tags() chan_est = None for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': self.assertEqual(pmt.to_long(tag.value), carr_offset) if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': chan_est = pmt.c32vector_elements(tag.value) self.assertEqual(chan_est, chanest_exp) self.assertEqual(sink.data(), tuple(numpy.multiply(shift_tuple(data_symbol, carr_offset), channel)))
def run_flow_graph(sync_sym1, sync_sym2, data_sym): top_block = gr.top_block() carr_offset = random.randint(-max_offset/2, max_offset/2) * 2 tx_data = shift_tuple(sync_sym1, carr_offset) + \ shift_tuple(sync_sym2, carr_offset) + \ shift_tuple(data_sym, carr_offset) channel = [rand_range(min_chan_ampl, max_chan_ampl) * numpy.exp(1j * rand_range(0, 2 * numpy.pi)) for x in range(fft_len)] src = blocks.vector_source_c(tx_data, False, fft_len) chan = blocks.multiply_const_vcc(channel) noise = analog.noise_source_c(analog.GR_GAUSSIAN, wgn_amplitude) add = blocks.add_cc(fft_len) chanest = digital.ofdm_chanest_vcvc(sync_sym1, sync_sym2, 1) sink = blocks.vector_sink_c(fft_len) top_block.connect(src, chan, (add, 0), chanest, sink) top_block.connect(noise, blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), (add, 1)) top_block.run() channel_est = None carr_offset_hat = 0 rx_sym_est = [0,] * fft_len tags = sink.tags() for tag in tags: if pmt.symbol_to_string(tag.key) == 'ofdm_sync_carr_offset': carr_offset_hat = pmt.to_long(tag.value) self.assertEqual(carr_offset, carr_offset_hat) if pmt.symbol_to_string(tag.key) == 'ofdm_sync_chan_taps': channel_est = shift_tuple(pmt.c32vector_elements(tag.value), carr_offset) shifted_carrier_mask = shift_tuple(carrier_mask, carr_offset) for i in range(fft_len): if shifted_carrier_mask[i] and channel_est[i]: self.assertAlmostEqual(channel[i], channel_est[i], places=0) rx_sym_est[i] = (sink.data()[i] / channel_est[i]).real return (carr_offset, list(shift_tuple(rx_sym_est, -carr_offset_hat)))
def supply_rx_baseband(self): ## RX Spectrum if self.__dict__.has_key('rx_baseband'): return self.rx_baseband config = self.config fftlen = config.fft_length my_window = window.hamming(fftlen) #.blackmanharris(fftlen) rxs_sampler = vector_sampler(gr.sizeof_gr_complex,fftlen) rxs_trigger = gr.vector_source_b(concatenate([[1],[0]*199]),True) rxs_window = blocks.multiply_const_vcc(my_window) rxs_spectrum = gr.fft_vcc(fftlen,True,[],True) rxs_mag = gr.complex_to_mag(fftlen) rxs_avg = gr.single_pole_iir_filter_ff(0.01,fftlen) rxs_logdb = gr.nlog10_ff(20.0,fftlen,-20*log10(fftlen)) rxs_decimate_rate = gr.keep_one_in_n(gr.sizeof_float*fftlen,50) t = self.u if self.filter is None else self.filter self.connect(rxs_trigger,(rxs_sampler,1)) self.connect(t,rxs_sampler,rxs_window, rxs_spectrum,rxs_mag,rxs_avg,rxs_logdb, rxs_decimate_rate) if self._options.log: log_to_file(self, rxs_decimate_rate, "data/supply_rx.float") self.rx_baseband = rxs_decimate_rate return rxs_decimate_rate
def publish_rx_spectrum(self,fftlen): ## RX Spectrum fftlen = 256 my_window = window.hamming(fftlen) #.blackmanharris(fftlen) rxs_sampler = vector_sampler(gr.sizeof_gr_complex,fftlen) rxs_trigger = gr.vector_source_b(concatenate([[1],[0]*199]),True) rxs_window = blocks.multiply_const_vcc(my_window) rxs_spectrum = gr.fft_vcc(fftlen,True,[],True) rxs_mag = gr.complex_to_mag(fftlen) rxs_avg = gr.single_pole_iir_filter_ff(0.01,fftlen) rxs_logdb = gr.nlog10_ff(20.0,fftlen,-20*log10(fftlen)) rxs_decimate_rate = gr.keep_one_in_n(gr.sizeof_float*fftlen,1) msgq = gr.msg_queue(5) rxs_msg_sink = gr.message_sink(gr.sizeof_float*fftlen,msgq,True) self.connect(rxs_trigger,(rxs_sampler,1)) t = self.u if self.filter is None else self.filter self.connect(t,rxs_sampler,rxs_window, rxs_spectrum,rxs_mag,rxs_avg,rxs_logdb, rxs_decimate_rate, rxs_msg_sink) self.servants.append(corba_data_buffer_servant("spectrum",fftlen,msgq)) print "RXS trigger unique id", rxs_trigger.unique_id() print "Publishing RX baseband under id: spectrum"
def __init__(self, beta=0): gr.hier_block2.__init__( self, "Third Order Distortion", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.beta = beta ################################################## # Blocks ################################################## self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((beta, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_xx_0 = blocks.add_vcc(1) ################################################## # Connections ################################################## self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self, 0))
def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if(options.spec): self.u.set_subdev_spec(options.spec, 0) if(options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## # self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(1, samp_rate, 1, 0.35, 11*samp_rate)) 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_0 = blocks.vector_source_b((1,1,1,1), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.500, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="", access_code="11111111", pad_for_usrp=True, ), payload_length=0, ) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_gfsk_mod_0, self.blocks_multiply_const_vxx_0, hopper_block, self.u)
def __init__(self, alfa=0.35, samp_per_sym=5, bits_per_sym=2, constellation=[-1-1j,1-1j, 1+1j, -1+1j], len_sym_srrc=7, out_const_mul=0.4): gr.hier_block2.__init__( self, "Hier Tx", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.alfa = alfa self.samp_per_sym = samp_per_sym self.bits_per_sym = bits_per_sym self.constellation = constellation self.len_sym_srrc = len_sym_srrc self.out_const_mul = out_const_mul ################################################## # Variables ################################################## self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc) ################################################## # Blocks ################################################## self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf( samp_per_sym, (pulso), 100) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((constellation), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((out_const_mul, )) if DEBUG: self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_ini", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "./file_tx_2bits", False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_out", False) self.blocks_file_sink_2.set_unbuffered(True) self.blocks_file_sink_3 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_tx_sym", False) self.blocks_file_sink_3.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self, 0)) self.connect((self, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) if DEBUG: self.connect((self, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_file_sink_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_file_sink_3, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=70, decimation=64, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768" ) self.osmosdr_sink_0.set_sample_rate(10e6) self.osmosdr_sink_0.set_center_freq(800e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(19, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.fft_vxx_0 = fft.fft_vcc(2048, False, (window.rectangular(2048)), True, 10) self.dvbt_symbol_inner_interleaver_0 = dvbt.symbol_inner_interleaver(1512, dvbt.T2k, 1) self.dvbt_reference_signals_0 = dvbt.reference_signals(gr.sizeof_gr_complex, 1512, 2048, dvbt.QAM16, dvbt.NH, dvbt.C1_2, dvbt.C1_2, dvbt.G1_32, dvbt.T2k, 0, 0) self.dvbt_reed_solomon_enc_0 = dvbt.reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, 8) self.dvbt_inner_coder_0 = dvbt.inner_coder(1, 1512, dvbt.QAM16, dvbt.NH, dvbt.C1_2) self.dvbt_energy_dispersal_0 = dvbt.energy_dispersal(1) self.dvbt_dvbt_map_0 = dvbt.dvbt_map(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k, 1) self.dvbt_convolutional_interleaver_0 = dvbt.convolutional_interleaver(136, 12, 17) self.dvbt_bit_inner_interleaver_0 = dvbt.bit_inner_interleaver(1512, dvbt.QAM16, dvbt.NH, dvbt.T2k) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(2048, 2048+64, 0, "") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.0022097087, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "test.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbt_energy_dispersal_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dvbt_bit_inner_interleaver_0, 0), (self.dvbt_symbol_inner_interleaver_0, 0)) self.connect((self.dvbt_convolutional_interleaver_0, 0), (self.dvbt_inner_coder_0, 0)) self.connect((self.dvbt_dvbt_map_0, 0), (self.dvbt_reference_signals_0, 0)) self.connect((self.dvbt_energy_dispersal_0, 0), (self.dvbt_reed_solomon_enc_0, 0)) self.connect((self.dvbt_inner_coder_0, 0), (self.dvbt_bit_inner_interleaver_0, 0)) self.connect((self.dvbt_reed_solomon_enc_0, 0), (self.dvbt_convolutional_interleaver_0, 0)) self.connect((self.dvbt_reference_signals_0, 0), (self.fft_vxx_0, 0)) self.connect((self.dvbt_symbol_inner_interleaver_0, 0), (self.dvbt_dvbt_map_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, nmessages=50, snr=10): gr.top_block.__init__(self, "Wifi Loopback Nogui") ################################################## # Parameters ################################################## self.chan_est = chan_est self.encoding = encoding self.freq_offset = freq_offset self.interval = interval self.nmessages = nmessages self.snr = snr ################################################## # Variables ################################################## self.out_buf_size = out_buf_size = 96000 ################################################## # Blocks ################################################## self.wifi_phy_hier_0 = wifi_phy_hier( encoding=encoding, chan_est=chan_est, ) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=.5**.5, frequency_offset=freq_offset, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm_n" + str(nmessages) + "_s" + str(snr) + "_e" + str(encoding) + "_i" + str(interval) + ".pcap", False) self.blocks_file_sink_0_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self, fft_len=64, payload_bps=2): gr.hier_block2.__init__( self, "OFDM TX RX Hier paths", gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), gr.io_signaturev(2, 2, [gr.sizeof_char*1, gr.sizeof_gr_complex*1]), ) ################################################## # Parameters ################################################## self.fft_len = fft_len self.payload_bps = payload_bps ################################################## # Variables ################################################## self.len_tag_key = len_tag_key = "packet_len" ################################################## # Blocks ################################################## self.tag_gate_tx = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.ofdm_tx = ofdm_tools.ofdm_txrx_modules.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=payload_bps, rolloff=0, debug_log=False, scramble_bits=False ) self.ofdm_rx = ofdm_tools.ofdm_txrx_modules.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=payload_bps, debug_log=False, scramble_bits=False ) self.multiply_const_tx = blocks.multiply_const_vcc((.01, )) self.agc_rx = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.agc_rx.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self, 0), (self.ofdm_tx, 0)) self.connect((self, 1), (self.agc_rx, 0)) self.connect((self.agc_rx, 0), (self.ofdm_rx, 0)) self.connect((self.ofdm_rx, 0), (self, 0)) self.connect((self.multiply_const_tx, 0), (self, 1)) self.connect((self.ofdm_tx, 0), (self.tag_gate_tx, 0)) self.connect((self.tag_gate_tx, 0), (self.multiply_const_tx, 0))
def __init__(self, chan_est=1, dopp=400, encoding=0, freq_offset=0, interval=500, nmessages=50, ntrials=0, resultdir="0", snr=10): gr.top_block.__init__(self, "Wifi Loopback Nogui") ################################################## # Parameters ################################################## self.chan_est = chan_est self.dopp = dopp self.encoding = encoding self.freq_offset = freq_offset self.interval = interval self.nmessages = nmessages self.ntrials = ntrials self.resultdir = resultdir self.snr = snr ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.out_buf_size = out_buf_size = 96000 self.ndopp = ndopp = dopp/samp_rate ################################################## # Blocks ################################################## self.wifi_phy_hier_0 = wifi_phy_hier( encoding=encoding, chan_est=chan_est, ) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.foo_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_selective_fading_model_0 = channels.selective_fading_model( 8, ndopp, False, 4.0, ntrials, (0, 0.00003, 0.000064, 0.0032, 0.003232, 0.0064, 0.006432, 0.006464, 0.0096, 0.009632, 0.009664), (1, 1, 1, 0.234, 0.234, 0.003, 0.003, 0.003, 0.005, 0.005, 0.005), 8 ) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((((10**(snr/10.0))**0.5)/(2**0.5), )) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "" + resultdir + "/ofdm_" + str(ntrials) + "_" + str(nmessages) + "_" + str(snr) + "_" + str(encoding) + "_" + str(interval) + ".pcap", False) self.blocks_file_sink_0_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_selective_fading_model_0, 0)) self.connect((self.channels_selective_fading_model_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vv009 4Kfft") ################################################## # Variables ################################################## self.samp_rate = samp_rate = (8000000.0 * 8) / 7 ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0,buffers=128,buflen=32768" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(429e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(18, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(-8, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(8750000, 0) self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP7, dvbt2.GI_1_32, 100, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_ON, dvbt2.BANDWIDTH_8_0_MHZ, 4096) self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_32, 100, dvbt2.PREAMBLE_T2_SISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_64QAM, dvbt2.ROTATION_ON) self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3) self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3, dvbt2.MOD_64QAM) self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP7, dvbt2.GI_1_32, 100, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, ) self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3, dvbt2.MOD_64QAM, dvbt2.ROTATION_ON, 31, 3, dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_32, dvbt2.L1_MOD_16QAM, dvbt2.PILOT_PP7, 2, 100, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.INPUTMODE_NORMAL, dvbt2.RESERVED_OFF, dvbt2.L1_SCRAMBLED_OFF, dvbt2.INBAND_OFF) self.dvbt2_cellinterleaver_cc_0 = dvbt2.cellinterleaver_cc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_64QAM, 31, 3) self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3) self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3) self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C2_3, dvbt2.INPUTMODE_NORMAL, dvbt2.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(4096, 4096+4096/32, 0, "") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/run/shm/adv4k64qam.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbt2_bbheader_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.dvbt2_p1insertion_cc_0, 0)) self.connect((self.dvbt2_bbheader_bb_0, 0), (self.dvbt2_bbscrambler_bb_0, 0)) self.connect((self.dvbt2_bbscrambler_bb_0, 0), (self.dvbt2_bch_bb_0, 0)) self.connect((self.dvbt2_bch_bb_0, 0), (self.dvbt2_ldpc_bb_0, 0)) self.connect((self.dvbt2_cellinterleaver_cc_0, 0), (self.dvbt2_framemapper_cc_0, 0)) self.connect((self.dvbt2_framemapper_cc_0, 0), (self.dvbt2_freqinterleaver_cc_0, 0)) self.connect((self.dvbt2_freqinterleaver_cc_0, 0), (self.dvbt2_pilotgenerator_cc_0, 0)) self.connect((self.dvbt2_interleaver_bb_0, 0), (self.dvbt2_modulator_bc_0, 0)) self.connect((self.dvbt2_ldpc_bb_0, 0), (self.dvbt2_interleaver_bb_0, 0)) self.connect((self.dvbt2_modulator_bc_0, 0), (self.dvbt2_cellinterleaver_cc_0, 0)) self.connect((self.dvbt2_p1insertion_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, p, c, pw, ff, sr, br): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = sr self.channel_select = channel_select = c self.bit_rate = bit_rate = br ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(161999000, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) # 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_samp_rate(samp_rate) # self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request_t(161975000+50000*c,ff), 0) # self.uhd_usrp_sink_0.set_gain(-10, 0) # self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) # self.digital_gmsk_mod_0 = digital.gmsk_mod( # samples_per_symbol=int(samp_rate/bit_rate), # bt=0.4, # verbose=False, # log=False, # ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.9,)) self.AISTX_Build_Frame_0 = AISTX.Build_Frame(p, False, True) ################################################## # Connections ################################################## self.connect((self.AISTX_Build_Frame_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, atten=0, fd=50, fadeMode=0): gr.top_block.__init__(self, "Static RF or Single Path Rayleigh Faded RF") ################################################## # Parameters ################################################## self.atten = atten self.fd = fd self.fadeMode = fadeMode ################################################## # Variables ################################################## self.usrpRate = usrpRate = 250e3 self.fdTs = fdTs = fd*(1.0/usrpRate) self.centreFreq = centreFreq = 1e6 self.baseband_multiplier = baseband_multiplier = 0.25 ################################################## # Blocks ################################################## self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("0.0.0.0", 1234), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0_0.set_subdev_spec("A:AB", 0) self.uhd_usrp_sink_0_0_0.set_samp_rate(usrpRate) self.uhd_usrp_sink_0_0_0.set_center_freq(centreFreq, 0) self.uhd_usrp_sink_0_0_0.set_gain(0, 0) self.rccBlocks_channelModel_cc_0 = rccBlocks.channelModel_cc(randint(-10000,0), fdTs, 1.0, False, bool(fadeMode)) self.rccBlocks_VNXLabBrick_0 = rccBlocks.VNXLabBrick(atten) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 1.0) self.const_source_x_0 = gr.sig_source_c(0, gr.GR_CONST_WAVE, 0, 0, 1.0+1j) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, usrpRate) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((baseband_multiplier, )) ################################################## # Connections ################################################## self.connect((self.const_source_x_0, 0), (self.rccBlocks_channelModel_cc_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rccBlocks_VNXLabBrick_0, 0)) self.connect((self.rccBlocks_channelModel_cc_0, 0), (self.blocks_multiply_const_vxx_1, 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): grc_wxgui.top_block_gui.__init__(self, title="Qpsk Tx Uhd") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 320e3 self.gain = gain = 30 self.freq = freq = 2.421e9 ################################################## # Blocks ################################################## self.wxgui_constellationsink2_0 = constsink_gl.const_sink_c( self.GetWin(), title='Constellation Plot', sample_rate=samp_rate, frame_rate=5, const_size=2048, M=4, theta=0, loop_bw=6.28/100.0, fmax=0.06, mu=0.5, gain_mu=0.005, symbol_rate=samp_rate/4., omega_limit=0.005, ) self.Add(self.wxgui_constellationsink2_0.win) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=350e-3, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.5, )) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 255, 10000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_constellationsink2_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Txdigital") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.baud_rate = baud_rate = 49260 self.samp_rate = samp_rate = baud_rate*10 self.deviation = deviation = 180000 self.sps = sps = samp_rate/baud_rate self.samp_rate_TX = samp_rate_TX = samp_rate*2 self.modulation_index = modulation_index = (float)(deviation)/((float)(baud_rate / 2)) ################################################## # 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_samp_rate(samp_rate_TX) self.uhd_usrp_sink_0.set_center_freq(434e6, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate_TX, decimation=samp_rate, taps=None, fractional_bw=None, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/gema/Documents/RF12B.dat", True) self.analog_cpfsk_bc_0 = analog.cpfsk_bc((float)((float)(deviation)/baud_rate), 0.1, sps) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_cpfsk_bc_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.analog_cpfsk_bc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 6* 8000000.0 / 7 ################################################## # Blocks ################################################## self.fft_vxx_0 = fft.fft_vcc(2048, True, (window.rectangular(2048)), True, 1) self.dvbt_viterbi_decoder_0 = dvbt.viterbi_decoder(dvbt.QPSK, dvbt.NH, dvbt.C1_2, 768, 0, -1) self.dvbt_symbol_inner_interleaver_0 = dvbt.symbol_inner_interleaver(1512, dvbt.T2k, 0) self.dvbt_reed_solomon_dec_0 = dvbt.reed_solomon_dec(2, 8, 0x11d, 255, 239, 8, 51, 8) self.dvbt_ofdm_sym_acquisition_0 = dvbt.ofdm_sym_acquisition(1, 2048, 1705, 64, 30) self.dvbt_energy_descramble_0 = dvbt.energy_descramble(8) self.dvbt_dvbt_demap_0 = dvbt.dvbt_demap(1512, dvbt.QPSK, dvbt.NH, dvbt.T2k, 1) self.dvbt_demod_reference_signals_0 = dvbt.demod_reference_signals(gr.sizeof_gr_complex, 2048, 1512, dvbt.QPSK, dvbt.NH, dvbt.C1_2, dvbt.C1_2, dvbt.G1_32, dvbt.T2k, 0, 0) self.dvbt_convolutional_deinterleaver_0 = dvbt.convolutional_deinterleaver(136, 12, 17) self.dvbt_bit_inner_deinterleaver_0 = dvbt.bit_inner_deinterleaver(1512, dvbt.QPSK, dvbt.NH, dvbt.T2k) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_char*1, 1512) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.0022097087, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "testBB.bin", False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "test_out.ts", False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.dvbt_ofdm_sym_acquisition_0, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.dvbt_viterbi_decoder_0, 0)) self.connect((self.dvbt_bit_inner_deinterleaver_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.dvbt_convolutional_deinterleaver_0, 0), (self.dvbt_reed_solomon_dec_0, 0)) self.connect((self.dvbt_demod_reference_signals_0, 0), (self.dvbt_dvbt_demap_0, 0)) self.connect((self.dvbt_dvbt_demap_0, 0), (self.dvbt_symbol_inner_interleaver_0, 0)) self.connect((self.dvbt_energy_descramble_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.dvbt_ofdm_sym_acquisition_0, 0), (self.fft_vxx_0, 0)) self.connect((self.dvbt_reed_solomon_dec_0, 0), (self.dvbt_energy_descramble_0, 0)) self.connect((self.dvbt_symbol_inner_interleaver_0, 0), (self.dvbt_bit_inner_deinterleaver_0, 0)) self.connect((self.dvbt_viterbi_decoder_0, 0), (self.dvbt_convolutional_deinterleaver_0, 0)) self.connect((self.fft_vxx_0, 0), (self.dvbt_demod_reference_signals_0, 0))
def __init__(self, name="UHDSourceDummy", modulator=None, f=None): """ @param name Instance name. @param modulator """ self._modulator = modulator self._multiply = blocks.multiply_const_vcc((0.0, )) UHDPrototype.__init__(self, output_controller=self._multiply) UHDGenericArch.__init__(self, name=name, input_signature=gr.io_signature(0, 0, 0), output_signature=gr.io_signature(1, 1, gr.sizeof_gr_complex) )
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Bt Tx 1") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_0 = samp_rate_0 = 1e6 self.mod_index = mod_index = 0.32 self.freq = freq = 2404e6 ################################################## # Blocks ################################################## 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(sps) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1, bt=0.32, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "sync2", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "ax25_tx_test") ################################################## # Variables ################################################## self.tx_samp_rate = tx_samp_rate = 233645 self.baud = baud = 9600 self.tx_samp_per_sym = tx_samp_per_sym = tx_samp_rate/baud self.tx_freq = tx_freq = 450e6 ################################################## # Blocks ################################################## 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(tx_samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(10, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=tx_samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.Interfaces_ax25_queue_source_b_0 = Interfaces.ax25_queue_source_b('U', True) ################################################## # Connections ################################################## self.connect((self.Interfaces_ax25_queue_source_b_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, len_tag_key, fft_len, cp_len, occupied_carriers, pilot_symbols, pilot_carriers, sync_words): gr.hier_block2.__init__(self, "adaptive_ofdm_tx_bc", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.len_tag_key = len_tag_key self.fft_len = fft_len self.cp_len = cp_len self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.sync_words = sync_words self.select_adaptive_mod() self.create_header_blocks() self.create_payload_blocks() self.tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex, self.len_tag_key, 0) self.create_ofdm_blocks() self.multiply = blocks.multiply_const_vcc((1/math.sqrt(self.fft_len), )) self.connect_blocks()
def __init__(self, sensingprocessorLambda=0): gr.hier_block2.__init__( self, "Sensing Platform - Central Office", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signaturev(2, 2, [gr.sizeof_float*1, gr.sizeof_float*1]), ) self.message_port_register_hier_in("msg_harddecision") ################################################## # Parameters ################################################## self.sensingprocessorLambda = sensingprocessorLambda ################################################## # Blocks ################################################## self.sensing_eigenvalue_cc_0 = sensing.eigenvalue_cc() self.sensing_decisionmaker_ff_0 = sensing.decisionmaker_ff() self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vff((0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0, )) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, sensingprocessorLambda) ################################################## # Connections ################################################## self.msg_connect((self.sensing_decisionmaker_ff_0, 'hard_decision'), (self, 'msg_harddecision')) self.connect((self.analog_const_source_x_0_0, 0), (self.sensing_decisionmaker_ff_0, 1)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_multiply_const_vxx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.sensing_eigenvalue_cc_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.sensing_decisionmaker_ff_0, 0)) self.connect((self, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.sensing_eigenvalue_cc_0, 0)) self.connect((self.sensing_decisionmaker_ff_0, 0), (self, 0)) self.connect((self.sensing_decisionmaker_ff_0, 1), (self, 1)) self.connect((self.sensing_eigenvalue_cc_0, 1), (self.blocks_add_xx_0_0, 1)) self.connect((self.sensing_eigenvalue_cc_0, 0), (self.blocks_add_xx_0_0, 0))
def __init__(self, N=12, M=256, start_index=10, mapping=0, modulation=16, cp_ratio=0.25): gr.hier_block2.__init__(self, "scfdma_transmitter_bc", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.N = N self.M = M self.start_index = start_index self.modulation = modulation self.cp_ratio = cp_ratio self.mapping = mapping ################################################## # Blocks ################################################## self.ofdm_scfdma_subcarrier_mapper_vcvc_0 = ofdm.scfdma_subcarrier_mapper_vcvc(N, M, start_index, mapping) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc([1.0/(M*N)]) self.ofdm_fbmc_symbol_creation_bvc_0 = ofdm.fbmc_symbol_creation_bvc(N, modulation) self.ofdm_cyclic_prefixer_0 = ofdm.cyclic_prefixer(M, int(M*(1+cp_ratio))) self.fft_vxx_0_0 = fft.fft_vcc(M, False, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(N, True, (), True, 1) ################################################## # Connections ################################################## self.connect((self.fft_vxx_0, 0), (self.ofdm_scfdma_subcarrier_mapper_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.ofdm_cyclic_prefixer_0, 0)) self.connect((self.ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0,0)) self.connect((self.blocks_multiply_const_vxx_0,0), (self,0)) self.connect((self.ofdm_fbmc_symbol_creation_bvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.ofdm_scfdma_subcarrier_mapper_vcvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self, 0), (self.ofdm_fbmc_symbol_creation_bvc_0, 0))
def __init__(self, N=512 , NW=3 , K=5, fftshift=False, samp_rate = 1, rate = 10): gr.hier_block2.__init__(self, "loeve", gr.io_signature(2, 2, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_float*N)) self.check_parameters(N, NW, K) self.s2v1 = blocks.stream_to_vector(gr.sizeof_gr_complex, N) self.s2v2 = blocks.stream_to_vector(gr.sizeof_gr_complex, N) self.one_in_n1 = blocks.keep_one_in_n(gr.sizeof_gr_complex * N, max(1, int(samp_rate/N/rate))) self.one_in_n2 = blocks.keep_one_in_n(gr.sizeof_gr_complex * N, max(1, int(samp_rate/N/rate))) self.connect((self, 0), self.s2v1, self.one_in_n1) self.connect((self, 1), self.s2v2, self.one_in_n2) dpss = specest_gendpss.gendpss(N=N, NW=NW, K=K) self.mtm1 = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)] self.mtm2 = [eigenspectrum(dpss.dpssarray[i], fftshift) for i in xrange(K)] self.multipliers = [blocks.multiply_vcc(N) for i in xrange(K)] self.sum = blocks.add_vcc(N) self.divide = blocks.multiply_const_vcc([1./K]*N) self.c2mag = blocks.complex_to_mag_squared(N) self.connect_loeve(K) self.connect(self.sum, self.divide, self.c2mag, self)
def __init__(self): gr.top_block.__init__(self, "Wifi Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi 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", "wifi_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.tx_gain = tx_gain = 0.75 self.samp_rate = samp_rate = 10e6 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.lo_offset = lo_offset = 0 self.interval = interval = 300 self.freq = freq = 5890000000 self.encoding = encoding = 0 ################################################## # Blocks ################################################## self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200) self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "tx_gain", "counter_slider", float) self.top_layout.addWidget(self._tx_gain_win) self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int) self.top_layout.addWidget(self._pdu_length_win) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self._interval_range = Range(10, 1000, 1, 300, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider", int) self.top_layout.addWidget(self._interval_win) self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7] self._encoding_labels = [ "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4" ] self._encoding_group_box = Qt.QGroupBox("encoding") self._encoding_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._encoding_button_group = variable_chooser_button_group() self._encoding_group_box.setLayout(self._encoding_box) for i, label in enumerate(self._encoding_labels): radio_button = Qt.QRadioButton(label) self._encoding_box.addWidget(radio_button) self._encoding_button_group.addButton(radio_button, i) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod( self._encoding_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._encoding_options.index(i))) self._encoding_callback(self.encoding) self._encoding_button_group.buttonClicked[int].connect( lambda i: self.set_encoding(self._encoding_options[i])) self.top_layout.addWidget(self._encoding_group_box) self.wifi_phy_hier_0 = wifi_phy_hier( bandwidth=10e6, chan_est=0, encoding=encoding, frequency=5.89e9, sensitivity=0.56, ) 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_subdev_spec('A:B', 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0) self.ieee802_11_mac_0 = ieee802_11.mac( ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 255])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.01, 100, 1000) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern("".join("x" for i in range(pdu_length))), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_mac_0, 'app in')) self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.ieee802_11_mac_0, 'app in')) self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_mac_0, 'phy in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Hf Spectrum Simple") Qt.QWidget.__init__(self) self.setWindowTitle("Hf Spectrum Simple") 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", "hf_spectrum_simple") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 25e6 self.rx_freq = rx_freq = 12.5e6 self.offset = offset = 0 ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('SAMP_RATE' + ": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate( eng_notation.str_to_num( str(self._samp_rate_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._samp_rate_tool_bar, 8, 0, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._rx_freq_tool_bar = Qt.QToolBar(self) self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ' + ": ")) self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq)) self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit) self._rx_freq_line_edit.returnPressed.connect(lambda: self.set_rx_freq( eng_notation.str_to_num( str(self._rx_freq_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 8, 1, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel('offset' + ": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect(lambda: self.set_offset( eng_notation.str_to_num( str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 8, 2, 1, 1) for r in range(8, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_1 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="sc16", otw_format='sc16', channels=range(1), ), ) self.uhd_usrp_source_1.set_samp_rate(samp_rate) self.uhd_usrp_source_1.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_1.set_center_freq( uhd.tune_request(rx_freq, samp_rate / 2), 0) self.uhd_usrp_source_1.set_gain(0, 0) self.uhd_usrp_source_1.set_antenna('RX2', 0) self.uhd_usrp_source_1.set_auto_dc_offset(True, 0) self.uhd_usrp_source_1.set_auto_iq_balance(True, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(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_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 4, 0, 4, 4) for r in range(4, 8): 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( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype rx_freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.010) self.qtgui_freq_sink_x_0.set_y_axis(-140, 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(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.fosphor_qt_sink_c_1 = fosphor.qt_sink_c() self.fosphor_qt_sink_c_1.set_fft_window(window.WIN_BLACKMAN_hARRIS) self.fosphor_qt_sink_c_1.set_frequency_range(0, samp_rate) self._fosphor_qt_sink_c_1_win = sip.wrapinstance( self.fosphor_qt_sink_c_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._fosphor_qt_sink_c_1_win, 0, 4, 9, 4) for r in range(0, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (1 / 65536.0, )) self.blocks_interleaved_short_to_complex_0 = blocks.interleaved_short_to_complex( True, False) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -1 * offset, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_interleaved_short_to_complex_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.fosphor_qt_sink_c_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.uhd_usrp_source_1, 0), (self.blocks_interleaved_short_to_complex_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.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.pld_const = pld_const = digital.constellation_rect(([ 0.707 + 0.707j, -0.707 + 0.707j, -0.707 - 0.707j, 0.707 - 0.707j ]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.pld_const.gen_soft_dec_lut(8) self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts self.samp_rate_array_MCR = samp_rate_array_MCR = [ 7500000, 5000000, 3750000, 3000000, 2500000, 2000000, 1500000, 1000000, 937500, 882352, 833333, 714285, 533333, 500000, 421052, 400000, 380952 ] self.rxmod = rxmod = digital.generic_mod(pld_const, False, sps, True, eb, False, False) self.rrc_taps = rrc_taps = firdes.root_raised_cosine( sps, sps, 1.0, eb, 11 * sps) self.ac_hex = ac_hex = [0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc] self.variable_qtgui_range_0_1 = variable_qtgui_range_0_1 = 39 self.variable_qtgui_range_0 = variable_qtgui_range_0 = 50 self.samp_rate = samp_rate = samp_rate_array_MCR[15] self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.rx_psf_taps = rx_psf_taps = firdes.root_raised_cosine( nfilts, sps * nfilts, 1.0, eb, 11 * sps * nfilts) self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc( rxmod.to_basic_block(), (ac_hex), ([1])) self.mark_delay = mark_delay = 87 self.frequencia_usrp = frequencia_usrp = 484e6 self.filt_delay_0 = filt_delay_0 = 1 + (taps_per_filt - 1) / 2 self.filt_delay = filt_delay = 1 + (len(rrc_taps) - 1) / 2 self.MCR = MCR = "master_clock_rate=60e6" ################################################## # Blocks ################################################## self._variable_qtgui_range_0_1_range = Range(0, 73, 1, 39, 200) self._variable_qtgui_range_0_1_win = RangeWidget( self._variable_qtgui_range_0_1_range, self.set_variable_qtgui_range_0_1, 'Gain_RX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_1_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._variable_qtgui_range_0_range = Range(0, 90, 1, 50, 200) self._variable_qtgui_range_0_win = RangeWidget( self._variable_qtgui_range_0_range, self.set_variable_qtgui_range_0, 'Gain_TX', "counter_slider", float) self.top_grid_layout.addWidget(self._variable_qtgui_range_0_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=F5EAC0", MCR)), 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_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_source_0.set_gain(variable_qtgui_range_0_1, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_auto_dc_offset(True, 0) self.uhd_usrp_source_0.set_auto_iq_balance(True, 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("serial=F5EAE1", MCR)), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_center_freq(frequencia_usrp, 0) self.uhd_usrp_sink_0_0.set_gain(variable_qtgui_range_0, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "RX USRP", #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(False) self.qtgui_time_sink_x_1_0.enable_grid(False) 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 = ['', '', '', '', '', '', '', '', '', ''] 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, 1, 4, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 5): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "TX USRP", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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, 3, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #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, 256) 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, 'packet_length_tag_key') 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(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, 2, 3, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 512, #size 1, #samp_rate "", #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(-100, 4000) 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, 15, 0, 'corr_est') self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) 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) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 3, 2, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 512, #size 1, #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(-100, 100) 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_TAG, qtgui.TRIG_SLOPE_POS, 0, 15, 0, 'corr_est') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not False: 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, 2, 2, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_1 = qtgui.const_sink_c( 1024, #size "RX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_1.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_1.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_1.enable_grid(False) self.qtgui_const_sink_x_0_0_0_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_1_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_1_win, 2, 1, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0_0_0 = qtgui.const_sink_c( 1024, #size "TX Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_0_0_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 512, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not False: 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, 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.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( sps, taps=(tx_rrc_taps), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( 6.28 / 100.0, pld_const.arity(), False) self.digital_correlate_access_code_xx_ts_0_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 1, 'packet_len') self.digital_corr_est_cc_0 = digital.corr_est_cc((modulated_sync_word), sps, mark_delay, 0.99) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( pld_const) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (pld_const.points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_stream_mux_0_1_0 = blocks.stream_mux( gr.sizeof_char * 1, (96, 896)) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 8, 1, '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb( 1, pld_const.bits_per_symbol(), '', False, gr.GR_MSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( pld_const.bits_per_symbol(), 1, '', False, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/trasmit_10_mb.txt', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0_2 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/Desktop/Trasmited/depois.txt', False) self.blocks_file_sink_0_0_0_2.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_1_0_1 = blocks.char_to_float(1, 1) self.acode_1104 = blocks.vector_source_b([ 0x1, 0x0, 0x1, 0x0, 0x1, 0x1, 0x0, 0x0, 0x1, 0x1, 0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x1, 0x0, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x1, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0 ], True, 1, []) ################################################## # Connections ################################################## self.connect((self.acode_1104, 0), (self.blocks_stream_mux_0_1_0, 0)) self.connect((self.blocks_char_to_float_1_0_1, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_const_sink_x_0_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_correlate_access_code_xx_ts_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_stream_mux_0_1_0, 1)) self.connect((self.blocks_stream_mux_0_1_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_char_to_float_1_0_1, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0_0, 0), (self.blocks_file_sink_0_0_0_2, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_const_sink_x_0_0_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_1_0, 0))
def __init__(self): gr.top_block.__init__(self, "Superposition coding with MPSK modulation") Qt.QWidget.__init__(self) self.setWindowTitle("Superposition coding with MPSK modulation") 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.snr_db = snr_db = 10 self.noisevar = noisevar = 10**(-snr_db / 10) self.block = block = 1000 self.alpha = alpha = .1 self.R = R = 100e3 ################################################## # Blocks ################################################## self._alpha_range = Range(0, 1, .01, .1, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, 'P1/P', "counter_slider", float) self.top_layout.addWidget(self._alpha_win) self._snr_db_range = Range(0, 20, 1, 10, 200) self._snr_db_win = RangeWidget(self._snr_db_range, self.set_snr_db, 'P/sigma^2 (dB)', "counter_slider", float) self.top_layout.addWidget(self._snr_db_win) self.qtgui_number_sink_0_0 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("BER 2 (Raw)") labels = ['BER', '', '', '', '', '', '', '', '', ''] 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.set_min(i, 0) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance( self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_win, 0, 1, 1, 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("BER1 (Raw)") labels = ['BER', '', '', '', '', '', '', '', '', ''] 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, 0) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_scrambler_bb_0_1 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_scrambler_bb_0_0 = digital.scrambler_bb(0xDA, 0x7F, 7) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_psk_mod_0_1 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) self.digital_psk_demod_0_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=2, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=4, differential=True, samples_per_symbol=2, excess_bw=0.35, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.digital_descrambler_bb_0_1 = digital.descrambler_bb(0xDA, 0x7F, 7) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, R, True) self.blocks_sub_xx_2 = blocks.sub_cc(1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( ((1 - alpha)**0.5, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (alpha**0.5, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=block * 100, bits_per_symbol=2, ) self.analog_random_source_x_1 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, block)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noisevar, -42) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.analog_random_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.analog_random_source_x_0_0_0, 0), (self.blks2_error_rate_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_scrambler_bb_0_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blks2_error_rate_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_sub_xx_2, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_psk_demod_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_sub_xx_2, 1)) self.connect((self.blocks_sub_xx_2, 0), (self.blocks_null_sink_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.digital_scrambler_bb_0_1, 0)) self.connect((self.digital_descrambler_bb_0_1, 0), (self.blks2_error_rate_0_0, 1)) self.connect((self.digital_psk_demod_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_psk_demod_0_0, 0), (self.digital_descrambler_bb_0_1, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_psk_mod_0_1, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_scrambler_bb_0_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_scrambler_bb_0_1, 0), (self.digital_psk_mod_0_1, 0))