def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vv019 Norot") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=429000000, y_per_div=20, y_divs=10, ref_level=10, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, size=(600,600), ) self.Add(self.wxgui_fftsink2_0.win) self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K_T2GI, dvbt2.PILOT_PP7, dvbt2.GI_1_128, 59, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_OFF, dvbt2.BANDWIDTH_1_7_MHZ, 32768) self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K_T2GI, dvbt2.GI_1_128, 59, dvbt2.PREAMBLE_T2_SISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_256QAM, dvbt2.ROTATION_OFF) self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5) self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5, dvbt2.MOD_256QAM) self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K_T2GI, dvbt2.PILOT_PP7, dvbt2.GI_1_128, 59, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, ) self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5, dvbt2.MOD_256QAM, dvbt2.ROTATION_OFF, 202, 3, dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K_T2GI, dvbt2.GI_1_128, dvbt2.L1_MOD_64QAM, dvbt2.PILOT_PP7, 2, 59, 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_256QAM, 202, 3) self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5) self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5) self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C3_5, dvbt2.INPUTMODE_HIEFF, dvbt2.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(32768, 32768+32768/128, 0, "") self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/vv019.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbt2_bbheader_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_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_throttle_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def test_with_tags_2s_rolloff(self): " With tags and a 2-sample rolloff " fft_len = 8 cp_len = 2 tag_name = "length" expected_result = (7.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0/2+1.0/2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0/2) tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(2) tag2 = gr.tag_t() tag2.offset = 1 tag2.key = pmt.string_to_symbol("random_tag") tag2.value = pmt.from_long(42) src = blocks.vector_source_c(range(1, fft_len+1) * 2, False, fft_len, (tag, tag2)) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result) tags = [gr.tag_to_python(x) for x in sink.tags()] tags = sorted([(x.offset, x.key, x.value) for x in tags]) expected_tags = [ (0, tag_name, len(expected_result)), (fft_len+cp_len, "random_tag", 42) ] self.assertEqual(tags, expected_tags)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vv034 Dtg016") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 8000000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=429000000, y_per_div=20, y_divs=10, ref_level=10, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, size=(600,600), ) self.Add(self.wxgui_fftsink2_0.win) self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP5, dvbt2.GI_1_16, 500, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_OFF, dvbt2.BANDWIDTH_1_7_MHZ, 4096) self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_16, 500, dvbt2.PREAMBLE_T2_SISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_SHORT, dvbt2.MOD_QPSK, dvbt2.ROTATION_ON) self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5) self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.MOD_QPSK) self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.PILOT_PP5, dvbt2.GI_1_16, 500, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_SISO, ) self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.MOD_QPSK, dvbt2.ROTATION_ON, 204, 0, dvbt2.CARRIERS_NORMAL, dvbt2.FFTSIZE_4K, dvbt2.GI_1_16, dvbt2.L1_MOD_QPSK, dvbt2.PILOT_PP5, 2, 500, 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_SHORT, dvbt2.MOD_QPSK, 204, 0) self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5) self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5) self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_SHORT, dvbt2.C4_5, dvbt2.INPUTMODE_HIEFF, dvbt2.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(4096, 4096+4096/16, 0, "") self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/re/xfer/vv034.ts", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.dvbt2_bbheader_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_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_throttle_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def test_wo_tags_2s_rolloff(self): " No tags, but have a 2-sample rolloff " fft_len = 8 cp_len = 2 rolloff = 2 expected_result = ( 7.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8) src = blocks.vector_source_c(range(1, fft_len + 1) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, rolloff) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def test_001_t(self): # set up fg test_len = 1000 fft_len = 100 cp_len = fft_len / 4 in_data = list(range(0, fft_len)) * (test_len // fft_len) src = blocks.vector_source_c(in_data) s2v = blocks.stream_to_vector(8, fft_len) s2ts = blocks.stream_to_tagged_stream(8, fft_len, test_len / fft_len, 'packet_len') cp_add = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 0, 'packet_len') cp_remove = radar.ofdm_cyclic_prefix_remover_cvc( fft_len, cp_len, 'packet_len') v2s = blocks.vector_to_stream(8, fft_len) snk = blocks.vector_sink_c() self.tb.connect(src, s2v, s2ts, cp_add, cp_remove, v2s, snk) self.tb.run() # check data out_data = snk.data() out_data_real = [0] * len(out_data) for k in range(len(out_data)): out_data_real[k] = out_data[k].real for k in range(len(in_data)): self.assertEqual(in_data[k], out_data_real[k])
def __init__(self): gr.hier_block2.__init__(self, "ofdm_tx", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.sequencr = aux.insert_sequence_numbers_bb() self.encoder = aux.encoder_reed_solomon_bb() self.framer = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, config.get_bytes_per_frame(), LEN_TAG_KEY) #divide the incoming data streams in frames self.connect(self, self.sequencr, self.encoder, self.framer) #We can do some byte scrambling if needed (variable modulus modulation ) self.unpacker_data_stream = blocks.repack_bits_bb( #modulation of the data (split the bytes, and modulate the split bytes 8, config.get_bits_per_symbol(), LEN_TAG_KEY) self.modulator_data_stream = digital.chunks_to_symbols_bc( config.get_constellation().points()) self.connect(self.framer, self.unpacker_data_stream, self.modulator_data_stream) self.allocator = digital.ofdm_carrier_allocator_cvc( config.get_fft_length(), occupied_carriers=config.get_data_tones(), pilot_carriers=config.get_pilot_tones(), pilot_symbols=config.get_pilot_symbols(), sync_words=config.get_preambles(), len_tag_key=LEN_TAG_KEY) self.connect(self.modulator_data_stream, self.allocator) self.fft_block = fft.fft_vcc(config.get_fft_length(), False, (), True) self.connect(self.allocator, self.fft_block) self.prefixer = digital.ofdm_cyclic_prefixer( config.get_fft_length(), config.get_cp_length() + config.get_fft_length(), 0, LEN_TAG_KEY) self.burst_handler = aux.add_zeros_cc( 14, 104) #digital.burst_shaper_cc([],1040,1040,False, LEN_TAG_KEY) self.connect(self.fft_block, self.prefixer, self.burst_handler) self.connect(self.burst_handler, self)
def test_001_t (self): # set up fg test_len = 1000 fft_len = 100; cp_len = fft_len/4 in_data = range(0,fft_len)*(test_len/fft_len); src = blocks.vector_source_c(in_data) s2v = blocks.stream_to_vector(8,fft_len) s2ts = blocks.stream_to_tagged_stream(8,fft_len,test_len/fft_len,'packet_len') cp_add = digital.ofdm_cyclic_prefixer(fft_len,fft_len+cp_len,0,'packet_len') cp_remove = radar.ofdm_cyclic_prefix_remover_cvc(fft_len,cp_len,'packet_len') v2s = blocks.vector_to_stream(8,fft_len) snk = blocks.vector_sink_c() self.tb.connect(src,s2v,s2ts,cp_add,cp_remove,v2s,snk) self.tb.run () # check data out_data = snk.data() out_data_real = [0]*len(out_data) for k in range(len(out_data)): out_data_real[k] = out_data[k].real for k in range(len(in_data)): self.assertEqual(in_data[k],out_data_real[k])
def __init__(self, N_id_1, N_id_2, slot0=True, N_re=128, N_cp_ts=144, freq_corr=0): top = gr.top_block("foo") source = gr.vector_source_c(range(0, N_re), False, N_re) source.set_data(gen_sss_fd(N_id_1, N_id_2, N_re).get_sss(slot0)) fft = gr.fft_vcc(N_re, False, window.blackmanharris(1024), True) cp = digital.ofdm_cyclic_prefixer(N_re, N_re + N_cp_ts * N_re / 2048) if freq_corr != 0: freq_corr = gr.freq_xlating_fir_filter_ccf(1, 1, freq_corr, 15000 * N_re) sink = gr.vector_sink_c(1) top.connect(source, fft, cp) if freq_corr != 0: top.connect(cp, freq_corr, sink) else: top.connect(cp, sink) top.run() self.data = sink.data()
def create_ofdm_blocks(self): self.carrier_allocator = digital.ofdm_carrier_allocator_cvc( self.fft_len, self.occupied_carriers, self.pilot_carriers, self.pilot_symbols, self.sync_words, self.len_tag_key) self.ifft = fft.fft_vcc(self.fft_len, False, (), True, 1) ofdm_len = self.fft_len + self.cp_len self.ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( self.fft_len, ofdm_len, 0, self.len_tag_key)
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 test_with_tags_2s_rolloff_multiples_cps(self): "Two CP lengths, 2-sample rolloff and tags." fft_len = 8 cp_lengths = (3, 2, 2) rolloff = 2 tag_name = "ts_last" expected_result = [ 6.0 / 2, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0 / 2 # Last tail ] # First test tag tag0 = gr.tag_t() tag0.offset = 0 tag0.key = pmt.string_to_symbol("first_tag") tag0.value = pmt.from_long(24) # Second test tag tag1 = gr.tag_t() tag1.offset = 1 tag1.key = pmt.string_to_symbol("second_tag") tag1.value = pmt.from_long(42) src = blocks.vector_source_c( list(range(1, fft_len + 1)) * 2, False, fft_len, (tag0, tag1)) cp = digital.ofdm_cyclic_prefixer(fft_len, cp_lengths, rolloff, tag_name) sink = blocks.tsb_vector_sink_c(tsb_key=tag_name) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, fft_len, 2, tag_name), cp, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result) tags = [gr.tag_to_python(x) for x in sink.tags()] tags = sorted([(x.offset, x.key, x.value) for x in tags]) expected_tags = [(0, "first_tag", 24), (fft_len + cp_lengths[0], "second_tag", 42)] self.assertEqual(tags, expected_tags)
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 test_wo_tags_no_rolloff(self): " The easiest test: make sure the CP is added correctly. " fft_len = 8 cp_len = 2 expected_result = (6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7) src = blocks.vector_source_c(range(fft_len) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def test_wo_tags_no_rolloff(self): " The easiest test: make sure the CP is added correctly. " fft_len = 8 cp_len = 2 expected_result = (6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7) src = blocks.vector_source_c(list(range(fft_len)) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def test_wo_tags_2s_rolloff(self): " No tags, but have a 2-sample rolloff " fft_len = 8 cp_len = 2 rolloff = 2 expected_result = (7.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0 / 2+1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8) src = blocks.vector_source_c(list(range(1, fft_len+1)) * 2, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, rolloff) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def test_with_tags_2s_rolloff(self): " With tags and a 2-sample rolloff " fft_len = 8 cp_len = 2 tag_name = "length" expected_result = ( 7.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0 / 2) tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(2) tag2 = gr.tag_t() tag2.offset = 1 tag2.key = pmt.string_to_symbol("random_tag") tag2.value = pmt.from_long(42) src = blocks.vector_source_c( range(1, fft_len + 1) * 2, False, fft_len, (tag, tag2)) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result) tags = [gr.tag_to_python(x) for x in sink.tags()] tags = sorted([(x.offset, x.key, x.value) for x in tags]) expected_tags = [(0, tag_name, len(expected_result)), (fft_len + cp_len, "random_tag", 42)] self.assertEqual(tags, expected_tags)
def test_two(self): tb = gr.top_block() MTU = 4000 tagname = "length" packets = ( (0, 0, 0, 0)*32, #(0, 0, 1, 0)*16, #(1, 1, 1, 0)*4, ) data, tags = ofdm.utils.packets_to_vectors(packets, tagname) constellation = digital.bpsk_constellation() src = gr.vector_source_b(data, tags, False, 1) tag_scaler1 = ofdm.scale_tags(1, tagname, 0.125) packer = gr.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) crc = ofdm.crc32_bb(False, MTU, tagname) tag_scaler2 = ofdm.scale_tags(1, tagname, 8) unpacker = gr.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) mod1 = digital.chunks_to_symbols_bc(constellation.points()) mod2 = digital.chunks_to_symbols_bc(constellation.points()) occupied_carriers = ((1, 2, 4, 5),) fft_len = 16 header = ofdm.ofdm_header_bb(len(occupied_carriers[0])) mux1 = ofdm.tagged_stream_mux(gr.sizeof_gr_complex, 2, tagname, MTU) mux2 = ofdm.tagged_stream_mux(gr.sizeof_gr_complex*fft_len, 2, tagname, MTU) ifft = fft.fft_vcc(fft_len, forward=False, window=[1]*fft_len) cp_len = 4 rolloff_len = 2 cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len+cp_len, rolloff_len, tagname, MTU) pilot_symbols = ((1j,),) pilot_carriers = ((3,),) alloc = ofdm.carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, tagname) snk = gr.vector_sink_c() sync_packet = [0, 1, 0, 1, 0, 1] + [0]*10 sync_data, sync_tags = ofdm.utils.packets_to_vectors([sync_packet], tagname, vlen=fft_len) sync_header = gr.vector_source_c(sync_data, sync_tags, True, fft_len) tb.connect(src, tag_scaler1, packer, crc, tag_scaler2, unpacker, mod1, (mux1, 1)) tb.connect(crc, header, mod2, (mux1, 0)) tb.connect(mux1, alloc, (mux2, 1)) tb.connect(sync_header, (mux2, 0)) tb.connect(mux2, ifft, cp, snk) #tb.connect(src, tag_scaler1, packer, crc, tag_scaler2, unpacker, mod1, alloc, snk) tb.run()
def test_with_tags_2s_rolloff(self): " With tags and a 2-sample rolloff " fft_len = 8 cp_len = 2 tag_name = "ts_last" expected_result = [ 7.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0 / 2 ] tag2 = gr.tag_t() tag2.offset = 1 tag2.key = pmt.string_to_symbol("random_tag") tag2.value = pmt.from_long(42) src = blocks.vector_source_c( list(range(1, fft_len + 1)) * 2, False, fft_len, (tag2, )) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) sink = blocks.tsb_vector_sink_c(tsb_key=tag_name) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, fft_len, 2, tag_name), cp, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result) tags = [gr.tag_to_python(x) for x in sink.tags()] tags = sorted([(x.offset, x.key, x.value) for x in tags]) expected_tags = [(fft_len + cp_len, "random_tag", 42)] self.assertEqual(tags, expected_tags)
def __init__(self, options): """ @param options: parsed raw.ofdm_params """ self.params = ofdm_params(options) params = self.params gr.hier_block2.__init__( self, "ofdm_mod", gr.io_signature2(2, 2, gr.sizeof_gr_complex * params.data_tones, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature win = [] #[1 for i in range(self._fft_length)] # see gr_fft_vcc_fftw that it works differently if win = [1 1 1 ...] self.mapper = raw.ofdm_mapper(params.padded_carriers) self.preambles = digital.ofdm_insert_preamble(params.fft_length, params.padded_preambles) self.ifft = gr.fft_vcc(params.fft_length, False, win, True) self.cp_adder = digital.ofdm_cyclic_prefixer( params.fft_length, params.fft_length + params.cp_length) self.scale = gr.multiply_const_cc(1.0 / math.sqrt(params.fft_length)) self.connect((self, 0), self.mapper, (self.preambles, 0)) self.connect((self, 1), (self.preambles, 1)) self.connect(self.preambles, self.ifft, self.cp_adder, self.scale, self) if options.log: self.connect( self.mapper, gr.file_sink(gr.sizeof_gr_complex * params.fft_length, "tx-map.dat")) self.connect( self.preambles, gr.file_sink(gr.sizeof_gr_complex * params.fft_length, "tx-pre.dat")) self.connect( self.ifft, gr.file_sink(gr.sizeof_gr_complex * params.fft_length, "tx-ifft.dat")) self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, "tx-cp.dat"))
def __init__(self, N_id_1, N_id_2, slot0=True, N_re=128, N_cp_ts=144, freq_corr=0): top = gr.top_block("foo"); source = gr.vector_source_c(range(0,N_re), False, N_re) source.set_data(gen_sss_fd(N_id_1, N_id_2, N_re).get_sss(slot0)); fft = gr.fft_vcc(N_re, False, window.blackmanharris(1024), True) cp = digital.ofdm_cyclic_prefixer(N_re, N_re+N_cp_ts*N_re/2048) if freq_corr != 0: freq_corr = gr.freq_xlating_fir_filter_ccf(1, 1, freq_corr, 15000*N_re) sink = gr.vector_sink_c(1) top.connect(source, fft, cp) if freq_corr != 0: top.connect(cp, freq_corr, sink) else: top.connect(cp, sink) top.run() self.data = sink.data()
def __init__(self, N_id_2, N_re=128, N_cp_ts=144, freq_corr=0, repeat=False): gr.hier_block2.__init__( self, "PSS source time-domain", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex), ) self.pss_fd = pss_source_fd(N_id_2, N_re, repeat); self.fft = gr.fft_vcc(N_re, False, window.blackmanharris(1024), True) self.cp = digital.ofdm_cyclic_prefixer(N_re, N_re+N_cp_ts*N_re/2048) if freq_corr != 0: self.freq_corr = gr.freq_xlating_fir_filter_ccf(1, 1, freq_corr, 15000*N_re) self.connect(self.pss_fd, self.fft, self.cp) if freq_corr != 0: self.connect(self.cp, self.freq_corr, self) else: self.connect(self.cp, self)
def __init__(self, fft_size=64, paquete_tam=96, rolloff=0, samp_rate=100000): gr.hier_block2.__init__( self, "Cyclicprefix", gr.io_signature(1, 1, gr.sizeof_gr_complex * 64), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.fft_size = fft_size self.paquete_tam = paquete_tam self.rolloff = rolloff self.samp_rate = samp_rate ################################################## # Variables ################################################## self.length_tag_key = length_tag_key = "paquete_tam" ################################################## # Blocks ################################################## self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_size, fft_size + fft_size / 4, rolloff, length_tag_key) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, fft_len, cp_len, packet_len_tag, scale=1, verbose=True): gr.hier_block2.__init__(self, "ofdm_frames_to_basebandsignal_vcc", gr.io_signature(1, 1, fft_len*gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex) ) self.fft_len = fft_len self.cp_len = cp_len self.scale = scale self.packet_len_tag = packet_len_tag self.scaler = mimoots.ofdm_scale_symbol_vcvc( symbol_len=self.fft_len, scale=self.scale ) self.cyclic_prefixer = digital.ofdm_cyclic_prefixer( input_size=self.fft_len, output_size=self.fft_len+cp_len, rolloff_len=0, len_tag_key=self.packet_len_tag ) # Define blocks and connect them self.connect(self, self.scaler, self.cyclic_prefixer, self) if verbose==True: self.connect(self, blocks.file_sink( itemsize=self.fft_len*gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_input.gr') ) self.connect(self.scaler, blocks.file_sink( itemsize=self.fft_len*gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_scaler.gr') ) self.connect(self.cyclic_prefixer, blocks.file_sink( itemsize=gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_cyclic_prefixer.gr') )
def __init__(self, fft_len, cp_len, packet_len_tag, scale=1, verbose=True): gr.hier_block2.__init__( self, "ofdm_frames_to_basebandsignal_vcc", gr.io_signature(1, 1, fft_len * gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.fft_len = fft_len self.cp_len = cp_len self.scale = scale self.packet_len_tag = packet_len_tag self.scaler = mimoots.ofdm_scale_symbol_vcvc(symbol_len=self.fft_len, scale=self.scale) self.cyclic_prefixer = digital.ofdm_cyclic_prefixer( input_size=self.fft_len, output_size=self.fft_len + cp_len, rolloff_len=0, len_tag_key=self.packet_len_tag) # Define blocks and connect them self.connect(self, self.scaler, self.cyclic_prefixer, self) if verbose == True: self.connect( self, blocks.file_sink( itemsize=self.fft_len * gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_input.gr')) self.connect( self.scaler, blocks.file_sink( itemsize=self.fft_len * gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_scaler.gr')) self.connect( self.cyclic_prefixer, blocks.file_sink( itemsize=gr.sizeof_gr_complex, filename='ofdm_frames_to_basebandsignal_cyclic_prefixer.gr' ))
def __init__(self, mod_name="", fft_len=32): gr.hier_block2.__init__(self, mod_name, gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.random_source = \ blocks.vector_source_b( map(int, np.random.randint(0, 255, int(1e6))), True ) self.null = blocks.null_source(gr.sizeof_gr_complex * 1) self.rolloff = 2 self.fft_len = fft_len self.mult = blocks.multiply_const_vcc( (1.0 / np.sqrt(self.fft_len / 2), )) self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, self.fft_len) self.mux = blocks.stream_mux( gr.sizeof_gr_complex * 1, (self.fft_len / 4, self.fft_len / 2, self.fft_len / 4)) self.fft = fft.fft_vcc(self.fft_len, False, (()), True, 1) self.cp = digital.ofdm_cyclic_prefixer(self.fft_len, self.fft_len + self.fft_len / 4, self.rolloff, '')
def __init__(self, options): """ @param options: parsed raw.ofdm_params """ self.params = ofdm_params(options) params = self.params gr.hier_block2.__init__(self, "ofdm_mod", gr.io_signature2(2, 2, gr.sizeof_gr_complex*params.data_tones, gr.sizeof_char), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature win = [] #[1 for i in range(self._fft_length)] # see gr_fft_vcc_fftw that it works differently if win = [1 1 1 ...] self.mapper = raw.ofdm_mapper(params.padded_carriers) self.preambles = digital.ofdm_insert_preamble(params.fft_length, params.padded_preambles) self.ifft = gr.fft_vcc(params.fft_length, False, win, True) self.cp_adder = digital.ofdm_cyclic_prefixer(params.fft_length, params.fft_length + params.cp_length) self.scale = gr.multiply_const_cc(1.0 / math.sqrt(params.fft_length)) self.connect((self,0), self.mapper, (self.preambles,0)) self.connect((self,1), (self.preambles,1)) self.connect(self.preambles, self.ifft, self.cp_adder, self.scale, self) if options.log: self.connect(self.mapper, gr.file_sink(gr.sizeof_gr_complex*params.fft_length, "tx-map.dat")) self.connect(self.preambles, gr.file_sink(gr.sizeof_gr_complex*params.fft_length, "tx-pre.dat")) self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex*params.fft_length, "tx-ifft.dat")) self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, "tx-cp.dat"))
def test_with_tags_2s_rolloff(self): " With tags and a 2-sample rolloff " fft_len = 8 cp_len = 2 tag_name = "ts_last" expected_result = (7.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1.0/2 7.0 / 2+1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, 1.0 / 2) tag2 = gr.tag_t() tag2.offset = 1 tag2.key = pmt.string_to_symbol("random_tag") tag2.value = pmt.from_long(42) src = blocks.vector_source_c(list(range(1, fft_len+1)) * 2, False, fft_len, (tag2,)) cp = digital.ofdm_cyclic_prefixer(fft_len, fft_len + cp_len, 2, tag_name) sink = blocks.tsb_vector_sink_c(tsb_key=tag_name) self.tb.connect(src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, fft_len, 2, tag_name), cp, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result) tags = [gr.tag_to_python(x) for x in sink.tags()] tags = sorted([(x.offset, x.key, x.value) for x in tags]) expected_tags = [ (fft_len+cp_len, "random_tag", 42) ] self.assertEqual(tags, expected_tags)
def __init__(self,DRMParameters): gr.top_block.__init__(self, "DRM Transmitter 1") ################################################## # Variables ################################################## self.text_message = text_message = DRMParameters.text_msg self.station_label = station_label = DRMParameters.station_label self.msc_prot_level_2 = msc_prot_level_2 = 1 self.long_interl = long_interl = True self.audio_sample_rate = audio_sample_rate = DRMParameters.audio_samp*1000 self.SO = SO = DRMParameters.so self.RM = RM = DRMParameters.rm self.tp = tp = drm.transm_params(RM, SO, False, 0, DRMParameters.msc_mod, 0, msc_prot_level_2, DRMParameters.sdc_mod, 0, long_interl, audio_sample_rate, station_label, text_message) self.samp_rate = samp_rate = 48e3 self.usrp_addr = DRMParameters.usrp_id self.output_name = DRMParameters.output_name self.center_freq = DRMParameters.center_freq*1e6 self.audio_file = DRMParameters.audio_file ################################################## # Blocks ################################################## if DRMParameters.uhd_found: self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((self.usrp_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 250 / 48) self.uhd_usrp_sink_0.set_center_freq(self.center_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TXA", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.fft_vxx_0 = fft.fft_vcc(tp.ofdm().nfft(), False, (), True, 1) self.drm_scrambler_bb_0_1 = drm.scrambler_bb(tp.sdc().L()) self.drm_scrambler_bb_0_0 = drm.scrambler_bb(tp.fac().L()) self.drm_scrambler_bb_0 = drm.scrambler_bb(tp.msc().L_MUX()) self.drm_mlc_fac_bc = drm.make_mlc( channel_type="FAC", tp=tp ) #SDC Configuration self.drm_mlc_sdc_bc= drm.make_mlc( channel_type="SDC", tp=tp ) #MSC Configuration self.drm_mlc_msc_bc = drm.make_mlc( channel_type="MSC", tp=tp ) self.drm_interleaver_cc_0 = drm.interleaver_cc((tp.msc().cell_interl_seq()), long_interl, drm.INTL_DEPTH_DRM) self.drm_generate_sdc_b_0 = drm.generate_sdc_b(tp) self.drm_generate_fac_b_0 = drm.generate_fac_b(tp) self.drm_audio_encoder_sb_0 = drm.audio_encoder_sb(tp) self.digital_ofdm_cyclic_prefixer_1 = digital.ofdm_cyclic_prefixer(tp.ofdm().nfft(), tp.ofdm().nfft()+tp.ofdm().nfft()*tp.ofdm().cp_ratio_enum()/tp.ofdm().cp_ratio_denom(), 0, "") self.cell_mapping_cc_0 = drm.cell_mapping_cc(tp, (tp.msc().N_MUX() * tp.ofdm().M_TF() * 8, tp.sdc().N() * 8, tp.fac().N() * tp.ofdm().M_TF() * 8)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) if DRMParameters.pulse_audio: self.audio_source_1 = audio.source(audio_sample_rate, "", True) else: self.blocks_wavfile_source_0 = blocks.wavfile_source(self.audio_file, False) if DRMParameters.gen_output: self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.output_name, 1, 48000, 16) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((7e-3, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((32768, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 7000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) if DRMParameters.gen_output: self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.drm_audio_encoder_sb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) if DRMParameters.pulse_audio: self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_0, 0)) else: self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.cell_mapping_cc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.drm_audio_encoder_sb_0, 0), (self.drm_scrambler_bb_0, 0)) self.connect((self.drm_generate_fac_b_0, 0), (self.drm_scrambler_bb_0_0, 0)) self.connect((self.drm_generate_sdc_b_0, 0), (self.drm_scrambler_bb_0_1, 0)) self.connect((self.drm_interleaver_cc_0, 0), (self.cell_mapping_cc_0, 0)) self.connect((self.drm_mlc_msc_bc, 0), (self.drm_interleaver_cc_0, 0)) self.connect((self.drm_mlc_sdc_bc, 0), (self.cell_mapping_cc_0, 1)) self.connect((self.drm_mlc_fac_bc, 0), (self.cell_mapping_cc_0, 2)) self.connect((self.drm_scrambler_bb_0, 0), (self.drm_mlc_msc_bc, 0)) self.connect((self.drm_scrambler_bb_0_0, 0), (self.drm_mlc_fac_bc, 0)) self.connect((self.drm_scrambler_bb_0_1, 0), (self.drm_mlc_sdc_bc, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_1, 0)) if DRMParameters.uhd_found: self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_null_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM_TX_RX_1") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM_TX_RX_1") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "OFDM_TX_RX_1") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) + list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), ) self.length_tag_key_rx = length_tag_key_rx = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 1000000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 30 self.length_tag_key = length_tag_key = "packet_len" self.header_len = header_len = 10 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key_rx, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=[], ), '', ) self.uhd_usrp_sink_0.set_center_freq(3.555e9, 0) self.uhd_usrp_sink_0.set_gain(31, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(0.5e6, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec()) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ), length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + 16, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( payload_mod.points(), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( header_mod.points(), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, 1, length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/local/repository/gnuradio/file_to_transmit.txt', False, 0, 0) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.period = period = 50 self.pdu_length = pdu_length = 1000 self.out_buf_size = out_buf_size = 96000 self.header_formatter = header_formatter = ieee802_11.wifi_signal_field() self.encoding = encoding = 0 ################################################## # Blocks ################################################## self._period_range = Range(1, 10000, 1, 50, 200) self._period_win = RangeWidget(self._period_range, self.set_period, "period", "counter_slider", float) self.top_layout.addWidget(self._period_win) self._pdu_length_range = Range(10, 1500, 1, 1000, 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._encoding_options = (0, 1, 2, ) self._encoding_labels = ("BPSK 1/2" , "BPSK 3/4", "QPSK 1/2", ) self._encoding_tool_bar = Qt.QToolBar(self) self._encoding_tool_bar.addWidget(Qt.QLabel("Encoding"+": ")) self._encoding_combo_box = Qt.QComboBox() self._encoding_tool_bar.addWidget(self._encoding_combo_box) for label in self._encoding_labels: self._encoding_combo_box.addItem(label) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(self._encoding_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._encoding_options.index(i))) self._encoding_callback(self.encoding) self._encoding_combo_box.currentIndexChanged.connect( lambda i: self.set_encoding(self._encoding_options[i])) self.top_layout.addWidget(self._encoding_tool_bar) self.qtgui_time_sink_x_0_0_0_1_0_1 = qtgui.time_sink_c( 2**10, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_1_0_1.set_update_time(1) self.qtgui_time_sink_x_0_0_0_1_0_1.set_y_axis(-0.1, 1000) self.qtgui_time_sink_x_0_0_0_1_0_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0_1_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_1_0_1.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.001, 5e-3, 0, "FISTOR") self.qtgui_time_sink_x_0_0_0_1_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0_1_0_1.enable_grid(True) self.qtgui_time_sink_x_0_0_0_1_0_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_1_0_1.disable_legend() labels = ["correlation I", "correlation Q", "correlation_big", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_1_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_1_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_1_0_1_win) self.ieee802_11_ofdm_mapper_0 = ieee802_11.ofdm_mapper(encoding, False) 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, 255])) (self.ieee802_11_ofdm_mac_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_mac_0).set_min_output_buffer(96000) self.ieee802_11_chunks_to_symbols_xx_0 = ieee802_11.chunks_to_symbols() (self.ieee802_11_chunks_to_symbols_xx_0).set_min_output_buffer(96000) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.0001, 5000, 5000) (self.foo_packet_pad2_0).set_processor_affinity([3]) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1/52**.5] * 64)), True, 1) (self.fft_vxx_0_0).set_min_output_buffer(96000) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len") self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(64, 64+16, 2, "packet_len") (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(96000) self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc(64, (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),), ((-21, -7, 7, 21), ), ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)), ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746-1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746+1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0-1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0-1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0-1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 0, 0, 0, 0)), "packet_len") (self.digital_ofdm_carrier_allocator_cvc_0_0_0).set_min_output_buffer(96000) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([-1, 1]), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, "packet_len", 1) (self.blocks_tagged_stream_mux_0).set_min_output_buffer(96000) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length)) + "1234"), period) (self.blocks_message_strobe_0_0).set_processor_affinity([3]) (self.blocks_message_strobe_0_0).set_min_output_buffer(96000) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.ieee802_11_ofdm_mapper_0, 'in')) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.qtgui_time_sink_x_0_0_0_1_0_1, 0)) self.connect((self.ieee802_11_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.ieee802_11_ofdm_mapper_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.ieee802_11_ofdm_mapper_0, 0), (self.ieee802_11_chunks_to_symbols_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simu Chaine") Qt.QWidget.__init__(self) self.setWindowTitle("Simu Chaine") 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", "simu_chaine") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 5000000 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len = packet_len = 96 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=30CEEB2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2.492e9, 0) self.uhd_usrp_source_0.set_gain(40, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=30CEECB", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), packet_length_tag_key, ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.492e9, 0) self.uhd_usrp_sink_0.set_gain(100, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "Rx", #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_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): 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_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.pir_print_bytes_bb_0 = pir.print_bytes_bb() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), packet_length_tag_key) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len / 4, False) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, "", 0, "", True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len / 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len / 4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, packet_length_tag_key) self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc( (sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len / 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), ) self.digital_crc32_bb_0_0 = digital.crc32_bb(False, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_corr_est_cc_0 = digital.corr_est_cc( ((0.00000 - 0.00000j, -0.23756 + 0.06817j, 0.02455 - 0.06790j, -0.02923 + 0.05414j, 0.00701 - 0.10558j, 0.07080 - 0.00739j, 0.04334 + 0.00660j, -0.11691 + 0.08759j, 0.09375 + 0.06250j, 0.04313 - 0.10143j, 0.00862 - 0.03317j, -0.05702 + 0.07170j, -0.09857 - 0.09157j, 0.02654 + 0.03204j, -0.03675 - 0.04537j, 0.06443 + 0.17533j, 0.04419 + 0.00000j, 0.06443 - 0.17533j, -0.03675 + 0.04537j, 0.02654 - 0.03204j, -0.09857 + 0.09157j, -0.05702 - 0.07170j, 0.00862 + 0.03317j, 0.04313 + 0.10143j, 0.09375 - 0.06250j, -0.11691 - 0.08759j, 0.04334 - 0.00660j, 0.07080 + 0.00739j, 0.00701 + 0.10558j, -0.02923 - 0.05414j, 0.02455 + 0.06790j, -0.23756 - 0.06817j, 0.00000 + 0.00000j, 0.23756 - 0.06817j, -0.02455 + 0.06790j, 0.02923 - 0.05414j, -0.00701 + 0.10558j, -0.07080 + 0.00739j, -0.04334 - 0.00660j, 0.11691 - 0.08759j, -0.09375 - 0.06250j, -0.04313 + 0.10143j, -0.00862 + 0.03317j, 0.05702 - 0.07170j, 0.09857 + 0.09157j, -0.02654 - 0.03204j, 0.03675 + 0.04537j, -0.06443 - 0.17533j, -0.04419 + 0.00000j, -0.06443 + 0.17533j, 0.03675 - 0.04537j, -0.02654 + 0.03204j, 0.09857 - 0.09157j, 0.05702 + 0.07170j, -0.00862 - 0.03317j, -0.04313 - 0.10143j, -0.09375 + 0.06250j, 0.11691 + 0.08759j, -0.04334 + 0.00660j, -0.07080 - 0.00739j, -0.00701 - 0.10558j, 0.02923 + 0.05414j, -0.02455 - 0.06790j, 0.23756 + 0.06817j, 0.00000 - 0.00000j, -0.23756 + 0.06817j, 0.02455 - 0.06790j, -0.02923 + 0.05414j, 0.00701 - 0.10558j, 0.07080 - 0.00739j, 0.04334 + 0.00660j, -0.11691 + 0.08759j, 0.09375 + 0.06250j, 0.04313 - 0.10143j, 0.00862 - 0.03317j, -0.05702 + 0.07170j, -0.09857 - 0.09157j, 0.02654 + 0.03204j, -0.03675 - 0.04537j, 0.06443 + 0.17533j, 0.06250 + 0.03125j, -0.10790 - 0.08255j, 0.00182 + 0.03337j, 0.09586 - 0.07711j, 0.06872 + 0.05573j, 0.00373 + 0.04257j, -0.03565 - 0.03853j, -0.14193 + 0.01821j, -0.15089 - 0.03504j, 0.14492 - 0.01154j, 0.07984 + 0.05798j, -0.06544 - 0.02403j, 0.10927 - 0.05236j, 0.14303 + 0.12879j, -0.04601 - 0.13003j, -0.11594 + 0.05444j, -0.06250 + 0.00000j, -0.11594 - 0.05444j, -0.04601 + 0.13003j, 0.14303 - 0.12879j, 0.10927 + 0.05236j, -0.06544 + 0.02403j, 0.07984 - 0.05798j, 0.14492 + 0.01154j, -0.15089 + 0.03504j, -0.14193 - 0.01821j, -0.03565 + 0.03853j, 0.00373 - 0.04257j, 0.06872 - 0.05573j, 0.09586 + 0.07711j, 0.00182 - 0.03337j, -0.10790 + 0.08255j, 0.06250 - 0.03125j, -0.00527 - 0.11799j, 0.00182 + 0.05304j, 0.05923 + 0.02687j, -0.09460 + 0.11347j, 0.06227 - 0.14667j, -0.03565 + 0.03377j, -0.10488 - 0.05448j, 0.02589 + 0.09754j, 0.06134 - 0.07480j, 0.07984 + 0.06226j, -0.02766 + 0.02419j, 0.04162 - 0.02844j, -0.09425 - 0.14799j, -0.04601 + 0.09145j, 0.09289 + 0.12172j, -0.06250 + 0.00000j, 0.09289 - 0.12172j, -0.04601 - 0.09145j, -0.09425 + 0.14799j, 0.04162 + 0.02844j, -0.02766 - 0.02419j, 0.07984 - 0.06226j, 0.06134 + 0.07480j, 0.02589 - 0.09754j, -0.10488 + 0.05448j, -0.03565 - 0.03377j, 0.06227 + 0.14667j, -0.09460 - 0.11347j, 0.05923 - 0.02687j, 0.00182 - 0.05304j, -0.00527 + 0.11799j, 0.06250 + 0.03125j, -0.10790 - 0.08255j, 0.00182 + 0.03337j, 0.09586 - 0.07711j, 0.06872 + 0.05573j, 0.00373 + 0.04257j, -0.03565 - 0.03853j, -0.14193 + 0.01821j, -0.15089 - 0.03504j, 0.14492 - 0.01154j, 0.07984 + 0.05798j, -0.06544 - 0.02403j, 0.10927 - 0.05236j, 0.14303 + 0.12879j, -0.04601 - 0.13003j, -0.11594 + 0.05444j)), 1, 0, 0.999999999) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, "packet_len", 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, True) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_file_sink_1 = blocks.file_sink( gr.sizeof_char * 1, "/home/rhidra/pir/test/test_modules/out.txt", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_crc32_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.pir_print_bytes_bb_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_header_payload_demux_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_0, 0)) self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0), (self.digital_ofdm_serializer_vcc_payload, 0)) self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload, 0), (self.digital_constellation_decoder_cb_1, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.digital_header_payload_demux_0, 1)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_1, 0))
def __init__(self, data=[ [], ], fft_len=64, cp_len=16, nofdm_symbols=10, nofdm_frames=1, ofdm_symbol_scale=1, constellation=digital.constellation_bpsk(), occupied_carriers=(range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ), pilot_carriers=((-21, -7, 7, 21), ), pilot_symbols=tuple([ (1, -1, 1, -1), ]), scale=1.0, seq_seed=42, debug=False): gr.hier_block2.__init__( self, "ofdm_create_frames_bc", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature # ===================================================================== # Generate class-members # ===================================================================== self._def_occupied_carriers = occupied_carriers self._def_pilot_carriers = pilot_carriers self._def_pilot_symbols = pilot_symbols self._seq_seed = seq_seed self.data = data self.fft_len = fft_len self.cp_len = cp_len self.ofdm_symbol_scale = ofdm_symbol_scale self.constellation = constellation self.packet_len_tag = "packet_length" self.frame_length_tag_key = "frame_length" self.nofdm_symbols = nofdm_symbols self.nofdm_frames = nofdm_frames self.scale = scale self.debug = debug # ===================================================================== # Create data to convert into OFDM-Frames # ===================================================================== random.seed(self._seq_seed) self.data_len = utils.ofdm_get_data_len( nofdm_symbols=self.nofdm_symbols, noccupied_carriers=len(self._def_occupied_carriers[0]), constellation=constellation) if debug == True: print 'Frames: {}'.format(self.nofdm_frames) print 'Länge: {}'.format(self.data_len) (data_tosend, tags) = packet_utils.packets_to_vectors(self.data, self.packet_len_tag) # =================================================================== # Create all blocks # =================================================================== self.data_source = blocks.vector_source_b(data=data_tosend, vlen=1, tags=tags, repeat=False) self.payload_unpack = blocks.repack_bits_bb( k=8, l=self.constellation.bits_per_symbol(), len_tag_key=self.packet_len_tag) self.payload_mod = digital.chunks_to_symbols_bc( symbol_table=self.constellation.points()) self.allocator = digital.ofdm_carrier_allocator_cvc( fft_len=self.fft_len, occupied_carriers=self._def_occupied_carriers, pilot_carriers=self._def_pilot_carriers, pilot_symbols=self._def_pilot_symbols, sync_words=[ utils.ofdm_make_sync_word1(self.fft_len, self._def_occupied_carriers, self._def_pilot_carriers), utils.ofdm_make_sync_word2(self.fft_len, self._def_occupied_carriers, self._def_pilot_carriers), ], len_tag_key=self.packet_len_tag) self.ffter = fft.fft_vcc(fft_size=self.fft_len, forward=False, window=(), shift=True) self.scale = mimoots.ofdm_scale_symbol_vcvc(symbol_len=self.fft_len, scale=self.scale) self.cyclic_prefixer = digital.ofdm_cyclic_prefixer( input_size=self.fft_len, output_size=self.fft_len + cp_len, rolloff_len=0, len_tag_key=self.packet_len_tag) # =================================================================== # Connect all blocks # =================================================================== self.connect(self.data_source, self.payload_unpack, self.payload_mod, self.allocator, self.ffter, self.scale, self.cyclic_prefixer, self) #self.connect( # self.data_source, self.payload_mod, self.payload_unpack, # self.allocator, self.ffter, self.scale, self.cyclic_prefixer, # self #) # =================================================================== # Debug-Output # =================================================================== if self.debug == True: self.connect( self.data_source, blocks.file_sink(gr.sizeof_char, 'create-data_source.dat')) self.connect( self.payload_unpack, blocks.file_sink(gr.sizeof_char, 'create-payload_unpack.dat')) self.connect( self.payload_mod, blocks.file_sink(gr.sizeof_gr_complex, 'create-payload_mod.dat')) self.connect( self.allocator, blocks.file_sink(self.fft_len * gr.sizeof_gr_complex, 'create-allocator.dat')) self.connect( self.ffter, blocks.file_sink(self.fft_len * gr.sizeof_gr_complex, 'create-ffter.dat')) self.connect( self.scale, blocks.file_sink(self.fft_len * gr.sizeof_gr_complex, 'create-scale.dat')) self.connect( self.cyclic_prefixer, blocks.file_sink(gr.sizeof_gr_complex, 'create-cyclic_prefixer.dat'))
def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len, packet_length_tag_key=_def_packet_length_tag_key, occupied_carriers=_def_occupied_carriers, pilot_carriers=_def_pilot_carriers, pilot_symbols=_def_pilot_symbols, bps_header=1, bps_payload=1, sync_word1=None, sync_word2=None, rolloff=0, debug_log=False, scramble_bits=False ): gr.hier_block2.__init__(self, "ofdm_tx", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) ### Param init / sanity check ######################################## self.fft_len = fft_len self.cp_len = cp_len self.packet_length_tag_key = packet_length_tag_key self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.bps_header = bps_header self.bps_payload = bps_payload self.sync_word1 = sync_word1 if sync_word1 is None: self.sync_word1 = _make_sync_word1(fft_len, occupied_carriers, pilot_carriers) else: if len(sync_word1) != self.fft_len: raise ValueError("Length of sync sequence(s) must be FFT length.") self.sync_words = [self.sync_word1,] if sync_word2 is None: self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers) else: self.sync_word2 = sync_word2 if len(self.sync_word2): if len(self.sync_word2) != fft_len: raise ValueError("Length of sync sequence(s) must be FFT length.") self.sync_word2 = list(self.sync_word2) self.sync_words.append(self.sync_word2) if scramble_bits: self.scramble_seed = 0x7f else: self.scramble_seed = 0x00 # We deactivate the scrambler by init'ing it with zeros ### Header modulation ################################################ header_constellation = _get_constellation(bps_header) header_mod = digital.chunks_to_symbols_bc(header_constellation.points()) formatter_object = digital.packet_header_ofdm( occupied_carriers=occupied_carriers, n_syms=1, bits_per_header_sym=self.bps_header, bits_per_payload_sym=self.bps_payload, scramble_header=scramble_bits ) header_gen = digital.packet_headergenerator_bb(formatter_object.base(), self.packet_length_tag_key) header_payload_mux = blocks.tagged_stream_mux( itemsize=gr.sizeof_gr_complex*1, lengthtagname=self.packet_length_tag_key, tag_preserve_head_pos=1 # Head tags on the payload stream stay on the head ) self.connect( self, header_gen, header_mod, (header_payload_mux, 0) ) ### Payload modulation ############################################### payload_constellation = _get_constellation(bps_payload) payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points()) payload_scrambler = digital.additive_scrambler_bb( 0x8a, self.scramble_seed, 7, 0, # Don't reset after fixed length (let the reset tag do that) bits_per_byte=8, # This is before unpacking reset_tag_key=self.packet_length_tag_key ) payload_unpack = blocks.repack_bits_bb( 8, # Unpack 8 bits per byte bps_payload, self.packet_length_tag_key ) self.connect( self, payload_scrambler, payload_unpack, payload_mod, (header_payload_mux, 1) ) ### Create OFDM frame ################################################ allocator = digital.ofdm_carrier_allocator_cvc( self.fft_len, occupied_carriers=self.occupied_carriers, pilot_carriers=self.pilot_carriers, pilot_symbols=self.pilot_symbols, sync_words=self.sync_words, len_tag_key=self.packet_length_tag_key ) ffter = fft.fft_vcc( self.fft_len, False, # Inverse FFT (), # No window True # Shift ) cyclic_prefixer = digital.ofdm_cyclic_prefixer( self.fft_len, self.fft_len+self.cp_len, rolloff, self.packet_length_tag_key ) cyclic_prefixer.set_min_output_buffer(16000) self.connect(header_payload_mux, allocator, ffter, cyclic_prefixer, self)
def __init__(self, chan_est=0): gr.top_block.__init__(self, "Wifi Tx Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Tx Rx") 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_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.chan_est = chan_est ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 5e5 self.period = period = 10 self.pdu_length = pdu_length = 30 self.out_buf_size = out_buf_size = 96000 self.header_formatter = header_formatter = ieee802_11.wifi_signal_field( ) self.freq_sin = freq_sin = 1000 self.freq = freq = 943e6 self.encoding = encoding = 0 self.decimation = decimation = 40 ################################################## # Blocks ################################################## self._period_range = Range(1, 10000, 1, 10, 200) self._period_win = RangeWidget(self._period_range, self.set_period, "period", "counter_slider", float) self.top_layout.addWidget(self._period_win) self._pdu_length_range = Range(10, 1500, 1, 30, 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._encoding_options = ( 0, 1, 2, ) self._encoding_labels = ( "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", ) self._encoding_tool_bar = Qt.QToolBar(self) self._encoding_tool_bar.addWidget(Qt.QLabel("Encoding" + ": ")) self._encoding_combo_box = Qt.QComboBox() self._encoding_tool_bar.addWidget(self._encoding_combo_box) for label in self._encoding_labels: self._encoding_combo_box.addItem(label) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod( self._encoding_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._encoding_options.index(i))) self._encoding_callback(self.encoding) self._encoding_combo_box.currentIndexChanged.connect( lambda i: self.set_encoding(self._encoding_options[i])) self.top_layout.addWidget(self._encoding_tool_bar) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 32, #size 100, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 110) self.qtgui_time_sink_x_2.set_y_label("Frame error rata", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["Packets Reveiced", "", "", "", "", "", "", "", "", ""] 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_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) (self.qtgui_time_sink_x_2).set_processor_affinity([3]) self.qtgui_time_sink_x_0_0_0_1_0_1 = qtgui.time_sink_c( 2**10, #size samp_rate / 1000, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_1_0_1.set_update_time(1) self.qtgui_time_sink_x_0_0_0_1_0_1.set_y_axis(-0.1, 1000) self.qtgui_time_sink_x_0_0_0_1_0_1.set_y_label("Generated Samples", "") self.qtgui_time_sink_x_0_0_0_1_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_1_0_1.set_trigger_mode( qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.001, 5e-3, 0, "FISTOR") self.qtgui_time_sink_x_0_0_0_1_0_1.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0_1_0_1.enable_grid(True) self.qtgui_time_sink_x_0_0_0_1_0_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_1_0_1.disable_legend() labels = [ "correlation I", "correlation Q", "correlation_big", "", "", "", "", "", "", "" ] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_1_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_1_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_1_0_1_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.99, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0.set_update_time(0.0000010) self.qtgui_number_sink_0.set_title("Frame error Rata") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 100) 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_layout.addWidget(self._qtgui_number_sink_0_win) (self.qtgui_number_sink_0).set_processor_affinity([3]) self.nutaq_rtdex_source_0 = nutaq.rtdex_source( "nutaq_carrier_perseus_0", gr.sizeof_int, 1, 0) self.nutaq_rtdex_source_0.set_type(0) self.nutaq_rtdex_source_0.set_packet_size(8192) self.nutaq_rtdex_source_0.set_channels("0") (self.nutaq_rtdex_source_0).set_processor_affinity([1]) self.nutaq_rtdex_sink_0 = nutaq.rtdex_sink("nutaq_carrier_perseus_0", gr.sizeof_short, 1, 1) self.nutaq_rtdex_sink_0.set_type(0) self.nutaq_rtdex_sink_0.set_packet_size(8192) self.nutaq_rtdex_sink_0.set_channels("0") (self.nutaq_rtdex_sink_0).set_processor_affinity([3]) self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx( "nutaq_carrier_perseus_0", 1, 0) self.nutaq_radio420_tx_0_0.set_default_enable(1) self.nutaq_radio420_tx_0_0.set_default_tx_freq(943e6) self.nutaq_radio420_tx_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_tx_0_0.set_default_calibrate(0) self.nutaq_radio420_tx_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-15) self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(5) self.nutaq_radio420_tx_0_0.set_default_tx_gain3(0) self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(2) self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1) self.nutaq_radio420_rx_0.set_default_enable(1) self.nutaq_radio420_rx_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0.set_default_reference(0) self.nutaq_radio420_rx_0.set_default_datarate(samp_rate * 2 * decimation) self.nutaq_radio420_rx_0.set_default_calibrate(0) self.nutaq_radio420_rx_0.set_default_band(0) self.nutaq_radio420_rx_0.set_default_update_rate(1) self.nutaq_radio420_rx_0.set_default_rx_lna_gain(3) self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(3) self.nutaq_radio420_rx_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0.set_default_rx_gain3(3) self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0) self.nutaq_custom_register_0_2 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0_2.set_index(0) self.nutaq_custom_register_0_2.set_default_value( int((4e6) / samp_rate / 40 * (2**32))) self.nutaq_custom_register_0_2.set_update_rate(1) self.nutaq_custom_register_0_1 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0_1.set_index(2) self.nutaq_custom_register_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_1 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0_1.set_index(3) self.nutaq_custom_register_0_0_1.set_default_value(7) self.nutaq_custom_register_0_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0_0.set_index(6) self.nutaq_custom_register_0_0_0.set_default_value(600) self.nutaq_custom_register_0_0_0.set_update_rate(1) self.nutaq_custom_register_0_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 5) self.nutaq_custom_register_0_0.set_index(4) self.nutaq_custom_register_0_0.set_update_rate(1) self.nutaq_custom_register_0 = nutaq.custom_register( "nutaq_carrier_perseus_0", 4) self.nutaq_custom_register_0.set_index(1) self.nutaq_custom_register_0.set_default_value(3) self.nutaq_custom_register_0.set_update_rate(1) self.nutaq_carrier_perseus_0 = nutaq.carrier( 0, "nutaq_carrier_perseus_0", "192.168.0.101") self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short( 0.56, 2, False, False) (self.ieee802_11_ofdm_sync_short_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_sync_short_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long( sync_length, False, False) (self.ieee802_11_ofdm_sync_long_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_sync_long_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac( False, True) (self.ieee802_11_ofdm_parse_mac_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_parse_mac_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_mapper_0 = ieee802_11.ofdm_mapper(encoding, False) 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, 255])) (self.ieee802_11_ofdm_mac_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_mac_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols( chan_est, False) (self.ieee802_11_ofdm_equalize_symbols_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_equalize_symbols_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal( False, False) (self.ieee802_11_ofdm_decode_signal_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_decode_signal_0).set_min_output_buffer(96000) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac( False, False) (self.ieee802_11_ofdm_decode_mac_0).set_processor_affinity([3]) (self.ieee802_11_ofdm_decode_mac_0).set_min_output_buffer(96000) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) (self.ieee802_11_moving_average_xx_1).set_processor_affinity([3]) (self.ieee802_11_moving_average_xx_1).set_min_output_buffer(96000) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) (self.ieee802_11_moving_average_xx_0).set_processor_affinity([3]) (self.ieee802_11_moving_average_xx_0).set_min_output_buffer(96000) self.ieee802_11_chunks_to_symbols_xx_0 = ieee802_11.chunks_to_symbols() (self.ieee802_11_chunks_to_symbols_xx_0).set_min_output_buffer(96000) self._freq_sin_range = Range(-2.5e5, 2.5e5, 500, 1000, 200) self._freq_sin_win = RangeWidget(self._freq_sin_range, self.set_freq_sin, "freq_sin", "counter_slider", float) self.top_layout.addWidget(self._freq_sin_win) self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.0001, 100000, 100000) (self.foo_packet_pad2_0_0).set_processor_affinity([3]) (self.foo_packet_pad2_0_0).set_min_output_buffer(262144) self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1 / 52**.5] * 64)), True, 1) (self.fft_vxx_0_0).set_min_output_buffer(96000) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) (self.fft_vxx_0).set_processor_affinity([3]) (self.fft_vxx_0).set_min_output_buffer(96000) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), "packet_len") self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer( 64, 64 + 16, 2, "packet_len") (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(96000) self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc( 64, (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ), ((-21, -7, 7, 21), ), ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)), ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0 - 1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0 - 1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0 - 1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 0, 0, 0, 0)), "packet_len") (self.digital_ofdm_carrier_allocator_cvc_0_0_0 ).set_min_output_buffer(96000) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( ([-1, 1]), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, "packet_len", 1) (self.blocks_tagged_stream_mux_0).set_min_output_buffer(96000) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) (self.blocks_stream_to_vector_0).set_processor_affinity([3]) (self.blocks_stream_to_vector_0).set_min_output_buffer(96000) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.float_t, "packet_len") (self.blocks_pdu_to_tagged_stream_0).set_processor_affinity([3]) (self.blocks_pdu_to_tagged_stream_0).set_min_output_buffer(96000) self.blocks_null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_int * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) (self.blocks_multiply_xx_0).set_processor_affinity([3]) (self.blocks_multiply_xx_0).set_min_output_buffer(96000) self.blocks_message_strobe_0_0 = blocks.message_strobe( pmt.intern("".join("x" for i in range(pdu_length)) + "1234"), period) (self.blocks_message_strobe_0_0).set_processor_affinity([3]) (self.blocks_message_strobe_0_0).set_min_output_buffer(96000) self.blocks_interleave_0 = blocks.interleave(gr.sizeof_short * 1, 1) (self.blocks_interleave_0).set_processor_affinity([3]) self.blocks_float_to_short_0_0_0 = blocks.float_to_short(1, 2**11 - 1) (self.blocks_float_to_short_0_0_0).set_processor_affinity([3]) self.blocks_float_to_short_0_0 = blocks.float_to_short(1, 2**11 - 1) (self.blocks_float_to_short_0_0).set_processor_affinity([3]) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) (self.blocks_float_to_complex_0).set_processor_affinity([2]) self.blocks_divide_xx_0 = blocks.divide_ff(1) (self.blocks_divide_xx_0).set_processor_affinity([3]) (self.blocks_divide_xx_0).set_min_output_buffer(96000) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) (self.blocks_delay_0_0).set_processor_affinity([3]) (self.blocks_delay_0_0).set_min_output_buffer(96000) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) (self.blocks_delay_0).set_processor_affinity([3]) (self.blocks_delay_0).set_min_output_buffer(96000) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_int * 1, 1) (self.blocks_deinterleave_0).set_processor_affinity([1]) (self.blocks_deinterleave_0).set_min_output_buffer(32768) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() (self.blocks_conjugate_cc_0).set_processor_affinity([3]) (self.blocks_conjugate_cc_0).set_min_output_buffer(96000) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) (self.blocks_complex_to_mag_squared_0).set_processor_affinity([3]) (self.blocks_complex_to_mag_squared_0).set_min_output_buffer(96000) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) (self.blocks_complex_to_mag_0).set_processor_affinity([3]) (self.blocks_complex_to_mag_0).set_min_output_buffer(96000) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) (self.blocks_complex_to_float_0).set_processor_affinity([3]) (self.blocks_complex_to_float_0).set_min_output_buffer(16384) self.COWN_syncher2_0 = COWN.syncher2() (self.COWN_syncher2_0).set_processor_affinity([1]) self.COWN_resta_0 = COWN.resta() (self.COWN_resta_0).set_processor_affinity([1]) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.ieee802_11_ofdm_mapper_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.COWN_resta_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.COWN_syncher2_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_float_to_short_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_float_to_short_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_deinterleave_0, 3), (self.COWN_resta_0, 0)) self.connect((self.blocks_deinterleave_0, 2), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_short_0_0, 0), (self.blocks_interleave_0, 0)) self.connect((self.blocks_float_to_short_0_0_0, 0), (self.blocks_interleave_0, 1)) self.connect((self.blocks_interleave_0, 0), (self.nutaq_rtdex_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.foo_packet_pad2_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.qtgui_time_sink_x_0_0_0_1_0_1, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0)) self.connect((self.foo_packet_pad2_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.ieee802_11_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_mapper_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.ieee802_11_ofdm_mapper_0, 0), (self.ieee802_11_chunks_to_symbols_xx_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_null_sink_0_0_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.nutaq_rtdex_source_0, 0), (self.COWN_syncher2_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 5000000 self.rolloff = rolloff = 0 self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_len = packet_len = 96 self.header_mod = header_mod = digital.constellation_bpsk() self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, 1, length_tag_key) self.fft_len = fft_len = 64 ################################################## # 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(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2490000000, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), "packet_len") self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, rolloff, length_tag_key) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), length_tag_key) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, length_tag_key, 0) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def __init__(self, options, payload='', msgq_limit=2, pad_for_usrp=False): """ Hierarchical block for sending packets Packets to be sent are enqueued by calling send_pkt. The output is the complex modulated signal at baseband. @param options: pass modulation options from higher layers (fft length, occupied tones, etc.) @param msgq_limit: maximum number of messages in message queue @type msgq_limit: int @param pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples """ gr.hier_block2.__init__(self, "ofdm_mod", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._fft_length = 64 self._total_sub_carriers = 53 self._data_subcarriers = 48 self._cp_length = 16 self._regime = options.regime self._symbol_length = self._fft_length + self._cp_length self._role = options.role # assuming we have 100Ms/s going to the USRP2 and 80 samples per symbol # we can calculate the OFDM symboltime (in microseconds) # depending on the interpolation factor self._symbol_time = options.interp*(self._fft_length+self._cp_length)/100 win = [] if(self._regime == "1" or self._regime == "2"): rotated_const = ofdm_packet_utils.bpsk(self) elif (self._regime == "3" or self._regime == "4"): rotated_const = ofdm_packet_utils.qpsk(self) elif(self._regime == "5" or self._regime == "6"): rotated_const = ofdm_packet_utils.qam16(self) elif(self._regime == "7" or self._regime == "8"): rotated_const = ofdm_packet_utils.qam64(self) # map groups of bits to complex symbols self._pkt_input = ftw.ofdm_mapper(rotated_const, msgq_limit, self._data_subcarriers, self._fft_length) # insert pilot symbols (use pnc block * by lzyou) if self._role == 'A': print " >>> [FPNC]: *A* Insert Pilot" self.pilot = ftw.pnc_ofdm_pilot_cc(self._data_subcarriers, 1) elif self._role == 'B': print " >>> [FPNC]: *B* Insert Pilot" self.pilot = ftw.pnc_ofdm_pilot_cc(self._data_subcarriers, 2) else: print " >>> [FTW ]: Insert Pilot" self.pilot = ftw.ofdm_pilot_cc(self._data_subcarriers) # just for test #self.pilot = ftw.pnc_ofdm_pilot_cc(self._data_subcarriers, 1) #self.pilot = ftw.pnc_ofdm_pilot_cc(self._data_subcarriers, 2) # move subcarriers to their designated place and insert DC self.cmap = ftw.ofdm_cmap_cc(self._fft_length, self._total_sub_carriers) # inverse fast fourier transform self.ifft = gr.fft_vcc(self._fft_length, False, win, False) # add cyclic prefix from gnuradio import digital self.cp_adder = digital.ofdm_cyclic_prefixer(self._fft_length, self._symbol_length) self.connect(gr.null_source(gr.sizeof_char), (self.cp_adder, 1)) # Note: dirty modification to accomdate the API change # scale accordingly self.scale = gr.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) # we need to know the number of OFDM data symbols for preamble and zerogap info = ofdm_packet_utils.get_info(payload, options.regime, self._symbol_time) N_sym = info["N_sym"] # add training sequence (modify by lzyou) if self._role == 'A': print " >>> [FPNC]: *A* Insert Preamble" self.preamble= ofdm_packet_utils.insert_preamble(self._symbol_length, N_sym, 'A') elif self._role == 'B': print " >>> [FPNC]: *B* Insert Preamble" self.preamble= ofdm_packet_utils.insert_preamble(self._symbol_length, N_sym, 'B') else: print " >>> [FTW ]: Insert Preamble" self.preamble= ofdm_packet_utils.insert_preamble(self._symbol_length, N_sym) # append zero samples at the end (receiver needs that to decode) if self._role == None: print " >>> [FTW ]: Insert Zerogap" self.zerogap = ofdm_packet_utils.insert_zerogap(self._symbol_length, N_sym) else: print " >>> [FPNC]: Insert Zerogap" self.zerogap = ofdm_packet_utils.insert_zerogap(self._symbol_length, N_sym, 'FPNC') self.s2v = gr.stream_to_vector(gr.sizeof_gr_complex , self._symbol_length) self.v2s = gr.vector_to_stream(gr.sizeof_gr_complex , self._symbol_length) # swap real and immaginary component before sending (GNURadio/USRP2 bug!) if options.swapIQ == True: self.gr_complex_to_imag_0 = gr.complex_to_imag(1) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.connect((self.v2s, 0), (self.gr_complex_to_imag_0, 0)) self.connect((self.v2s, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_complex_to_imag_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_float_to_complex_0, 0), (self)) elif options.swapIQ == False: self.gr_complex_to_imag_0 = gr.complex_to_imag(1) self.gr_complex_to_real_0 = gr.complex_to_real(1) self.gr_float_to_complex_0 = gr.float_to_complex(1) self.connect((self.v2s, 0), (self.gr_complex_to_imag_0, 0)) self.connect((self.v2s, 0), (self.gr_complex_to_real_0, 0)) self.connect((self.gr_complex_to_imag_0, 0), (self.gr_float_to_complex_0, 1)) self.connect((self.gr_complex_to_real_0, 0), (self.gr_float_to_complex_0, 0)) self.connect((self.gr_float_to_complex_0, 0), (self)) # connect the blocks self.connect((self._pkt_input, 0), (self.pilot, 0)) self.connect((self._pkt_input,1), (self.preamble, 1)) self.connect((self.preamble,1), (self.zerogap, 1)) self.connect(self.pilot, self.cmap, self.ifft, self.cp_adder, self.scale, self.s2v, self.preamble, self.zerogap, self.v2s) if options.log: self.connect((self._pkt_input), gr.file_sink(gr.sizeof_gr_complex * self._data_subcarriers, "ofdm_mapper.dat")) self.connect(self.pilot, gr.file_sink(gr.sizeof_gr_complex * (5 + self._data_subcarriers), "ofdm_pilot.dat")) self.connect(self.cmap, gr.file_sink(gr.sizeof_gr_complex * self._fft_length, "ofdm_cmap.dat")) self.connect(self.ifft, gr.file_sink(gr.sizeof_gr_complex * self._fft_length, "ofdm_ifft.dat")) self.connect(self.cp_adder, gr.file_sink(gr.sizeof_gr_complex, "ofdm_cp_adder.dat")) self.connect(self.scale, gr.file_sink(gr.sizeof_gr_complex, "ofdm_scale.dat")) self.connect(self.preamble, gr.file_sink(gr.sizeof_gr_complex * self._symbol_length, "ofdm_preamble.dat")) self.connect(self.zerogap, gr.file_sink(gr.sizeof_gr_complex * self._symbol_length, "ofdm_zerogap.dat"))
def __init__( self, pilot_carriers=((-40, -14, 13, 39),), pilot_symbols=((1, 1, 1, -1),), occupied_carriers=( [ -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, ], ), samp_rate=10000, payload_mod="qpsk", sync_word1=[ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, 1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, -1.42, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ], sync_word2=[ 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, 0j, ], scramble_mode=0, crc_mode=0, clipper_mode=0, filter_mode=1, clipping_factor=10, ): gr.hier_block2.__init__( self, "Ofdm Radio Hier", 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.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.occupied_carriers = occupied_carriers self.samp_rate = samp_rate self.sync_word1 = sync_word1 self.sync_word2 = sync_word2 self.scramble_mode = scramble_mode self.crc_mode = crc_mode self.clipping_factor = clipping_factor self.clipper_mode = clipper_mode self.filter_mode = filter_mode if payload_mod == "qpsk": self.payload_mod = payload_mod = digital.constellation_qpsk() elif payload_mod == "qam16": self.payload_mod = payload_mod = digital.qam.qam_constellation(16, True, "none", False) elif payload_mod == "bpsk": self.payload_mod = payload_mod = digital.constellation_bpsk() ################################################## # Variables ################################################## self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1) + len(sync_word2)) / 2 self.scramble_seed = scramble_seed = 0x7F self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1 ) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True, ) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols ) self.forward_OOB = forward_OOB = [ 0.40789374966665903, 3.2351160543115207, 11.253435139165413, 22.423991613997735, 27.99555756436666, 22.423991613997735, 11.253435139165425, 3.235116054311531, 0.40789374966666014, ] self.feedback_OOB = feedback_OOB = [ 1.0, 6.170110168740749, 16.888669609673336, 26.73762881119027, 26.75444043101795, 17.322358010203928, 7.091659316015212, 1.682084643429639, 0.17795354282083842, ] self.cp_len_0 = cp_len_0 = fft_len / 4 self.cp_len = cp_len = fft_len / 4 self.active_carriers = active_carriers = len(occupied_carriers[0]) + 4 ################################################## # Blocks ################################################## self.ofdm_tools_clipper_0 = ofdm_tools.clipper_cc(clipping_factor) self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb( header_formatter.formatter(), "packet_len" ) self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len / 4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True ) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, "", 0, "", True ) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), cp_len, length_tag_key, True, 0 ) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), cp_len, length_tag_key, True, 1 ) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer( fft_len, fft_len + cp_len, rolloff, packet_length_tag_key ) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key ) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, () ) self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.digital_additive_scrambler_bb_txpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.digital_additive_scrambler_bb_rxpath_0 = digital.additive_scrambler_bb( 0x8A, 0x7F, 7, 0, bits_per_byte=8, reset_tag_key=self.packet_length_tag_key ) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0 ) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), packet_length_tag_key, False ) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb( payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True ) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.01,)) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len / 4) self.blks2_selector_0_2 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=clipper_mode, output_index=0 ) self.blks2_selector_0_1 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=scramble_mode, output_index=0 ) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_char * 1, num_inputs=2, num_outputs=1, input_index=crc_mode, output_index=0 ) self.blks2_selector_0_2_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=filter_mode, output_index=0 ) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0 / fft_len) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0) ) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect( (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0) ) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect( (self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0) ) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blks2_selector_0, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blks2_selector_0, 1)) self.connect((self.blks2_selector_0_1, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) self.connect((self.blks2_selector_0, 0), (self.digital_additive_scrambler_bb_txpath_0, 0)) self.connect((self.digital_additive_scrambler_bb_txpath_0, 0), (self.blks2_selector_0_1, 1)) self.connect((self.blks2_selector_0, 0), (self.blks2_selector_0_1, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self.blks2_selector_0_0, 1)) self.connect((self.digital_additive_scrambler_bb_rxpath_0, 0), (self.blks2_selector_0_0_0, 1)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_additive_scrambler_bb_rxpath_0, 0)) self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.blks2_selector_0_0_0, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.blks2_selector_0_0_0, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.ofdm_tools_clipper_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0_2, 0)) self.connect(self.blks2_selector_0_2, self.iir_filter_xxx_1) self.connect(self.blks2_selector_0_2, (self.blks2_selector_0_2_0, 0)) self.connect(self.iir_filter_xxx_1, (self.blks2_selector_0_2_0, 1)) self.connect(self.blks2_selector_0_2_0, (self, 1)) self.connect((self.ofdm_tools_clipper_0, 0), (self.blks2_selector_0_2, 1)) ################################################## # Asynch Message Connections ################################################## self.msg_connect( self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data", )
def main(args): d = 'Transmit a DVB-T signal using the bladeRF and gr-dtv' parser = argparse.ArgumentParser() mode_help = '# of carriers. Options: t2k, t8k (default).' parser.add_argument('-m', '--mode', dest='mode', default='t8k', type=str, help=mode_help) ch_help = 'channel width in MHz. Options: 5, 6, 7, 8 (default).' parser.add_argument('-c', '--channel', dest='channel', default=8, metavar='CH', type=int, help=ch_help) const_help = 'constellation. qpsk, qam16, qam64 (default).' parser.add_argument('-C', '--cons', dest='cons', default='qam64', metavar='TYPE', type=str, help=const_help) rate_help = 'Viterbi rate. 1/2, 2/3, 3/4, 5/6, 7/8 (default).' parser.add_argument('-r', '--rate', dest='rate', default='7/8', type=str, help=rate_help) guard_help = 'guard interval. 1/32 (default), 1/16, 1/8, 1/4.' parser.add_argument('-g', '--guard', dest='interval', default='1/32', metavar='D', type=str, help=guard_help) freq_help = 'center frequency (Hz). Default is 429e6.' parser.add_argument('-f', '--freq', dest='freq', default=429e6, type=float, help=freq_help) vga1_help = 'bladeRF TXVGA1 gain. Default is -6.' parser.add_argument('--txvga1', dest='txvga1', default=-6, metavar='gain', type=int, help=vga1_help) vga2_help = 'bladeRF TXVGA2 gain. Default is 9.' parser.add_argument('--txvga2', dest='txvga2', default=9, metavar='gain', type=int, help=vga2_help) outfile_help = 'write to specified file.' parser.add_argument('-o', '--output', dest='outfile', default=None, metavar='OUT', type=str, help=outfile_help) parser.add_argument('infile', metavar='input-file', type=str, help='Input file') args = parser.parse_args() print args if args.mode.lower() == 't2k': mode = dtv.T2k elif args.mode.lower() == 't8k': mode = dtv.T8k else: sys.stderr.write('Invalid mode provided: ' + args.mode + '\n') sys.exit(1) if args.channel < 5 or args.channel > 8: sys.stderr.write('Invalid channel: ' + str(args.channel) + '\n') sys.exit(1) else: channel_mhz = args.channel if args.cons.lower() == 'qpsk': constellation = dtv.MOD_QPSK elif args.cons.lower() == 'qam16': constellation = dtv.MOD_16QAM elif args.cons.lower() == 'qam64': constellation = dtv.MOD_64QAM else: sys.stderr.write('Invalid constellation type: ' + args.cons + '\n') sys.exit(1) if args.rate == '1/2': code_rate = dtv.C1_2 elif args.rate == '2/3': code_rate = dtv.C2_3 elif args.rate == '3/4': code_rate = dtv.C3_4 elif args.rate == '5/6': code_rate = dtv.C5_6 elif args.rate == '7/8': code_rate = dtv.C7_8 else: sys.stderr.write('Invalid Viterbi rate: ' + args.rate + '\n') sys.exit(1) if args.interval == '1/32': guard_interval = dtv.GI_1_32 elif args.interval == '1/16': guard_interval = dtv.GI_1_16 elif args.interval == '1/8': guard_interval = dtv.GI_1_8 elif args.interval == '1/4': guard_interval = dtv.GI_1_4 else: sys.stderr.write('Invalid guard interval: ' + args.interval + '\n') sys.exit(1) if args.freq < 300e6 or args.freq > 3.8e9: sys.stderr.write('Invalid center frequency: ' + str(args.freq) + '\n') sys.exit(1) else: center_freq = int(args.freq) if args.txvga1 < -35 or args.txvga1 > -4: sys.stderr.write('Invalid bladeRF TXVGA1 gain: ' + str(args.txvga1) + '\n') sys.exit(1) else: txvga1_gain = args.txvga1 if args.txvga2 < 0 or args.txvga2 > 25: sys.stderr.write('Invalid bladeRF TXVGA2 gain: ' + str(args.txvga2) + '\n') sys.exit(1) else: txvga2_gain = args.txvga2 infile = args.infile outfile = args.outfile symbol_rate = channel_mhz * 8000000.0 / 7 if mode == dtv.T2k: factor = 1 carriers = 2048 elif mode == dtv.T8k: factor = 4 carriers = 8192 if guard_interval == dtv.GI_1_32: gi = carriers / 32 elif guard_interval == dtv.GI_1_16: gi = carriers / 16 elif guard_interval == dtv.GI_1_8: gi = carriers / 8 elif guard_interval == dtv.GI_1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dtv_dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor) dtv_dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dtv_dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver((136 * factor), 12, 17) dtv_dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate) dtv_dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver((1512 * factor), constellation, dtv.NH, mode) dtv_dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver((1512 * factor), mode, 1) dtv_dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1) dtv_dvbt_reference_signals = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, guard_interval, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087, )) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dtv_dvbt_energy_dispersal) tb.connect(dtv_dvbt_energy_dispersal, dtv_dvbt_reed_solomon_enc) tb.connect(dtv_dvbt_reed_solomon_enc, dtv_dvbt_convolutional_interleaver) tb.connect(dtv_dvbt_convolutional_interleaver, dtv_dvbt_inner_coder) tb.connect(dtv_dvbt_inner_coder, dtv_dvbt_bit_inner_interleaver) tb.connect(dtv_dvbt_bit_inner_interleaver, dtv_dvbt_symbol_inner_interleaver) tb.connect(dtv_dvbt_symbol_inner_interleaver, dtv_dvbt_map) tb.connect(dtv_dvbt_map, dtv_dvbt_reference_signals) tb.connect(dtv_dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbt-blade.py input_file [output_file]\n"); sys.exit(1) channel_mhz = 6 mode = dvbt.T2k code_rate = dvbt.C1_2 constellation = dvbt.QPSK symbol_rate = channel_mhz * 8000000.0 / 7 center_freq = 441000000 txvga1_gain = -4 txvga2_gain = 25 if mode == dvbt.T2k: factor = 1 carriers = 2048 elif mode == dvbt.T8k: factor = 4 carriers = 8192 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dvbt_energy_dispersal = dvbt.energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dvbt.reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dvbt.convolutional_interleaver((136 * factor), 12, 17) dvbt_inner_coder = dvbt.inner_coder(1, (1512 * factor), constellation, dvbt.NH, code_rate) dvbt_bit_inner_interleaver = dvbt.bit_inner_interleaver((1512 * factor), constellation, dvbt.NH, mode) dvbt_symbol_inner_interleaver = dvbt.symbol_inner_interleaver((1512 * factor), mode, 1) dvbt_dvbt_map = dvbt.dvbt_map((1512 * factor), constellation, dvbt.NH, mode, 1) dvbt_reference_signals = dvbt.reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dvbt.NH, code_rate, code_rate, dvbt.G1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(64 * factor), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087 * 2.5, )) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_dvbt_map) tb.connect(dvbt_dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
src = blocks.file_source(gr.sizeof_char, infile, True) log.debug("source block initialized") dvbt2_bbheader = dvbt2.bbheader_bb(frame_size, code_rate, input_mode, dvbt2.INBAND_OFF, fec_blocks, 4000000) dvbt2_bbscrambler = dvbt2.bbscrambler_bb(frame_size, code_rate) dvbt2_bch = dvbt2.bch_bb(frame_size, code_rate) dvbt2_ldpc = dvbt2.ldpc_bb(frame_size, code_rate) dvbt2_interleaver = dvbt2.interleaver_bb(frame_size, code_rate, constellation) dvbt2_modulator = dvbt2.modulator_bc(frame_size, constellation, rotation) dvbt2_cellinterleaver = dvbt2.cellinterleaver_cc(frame_size, constellation, fec_blocks, ti_blocks) dvbt2_framemapper = dvbt2.framemapper_cc(frame_size, code_rate, constellation, rotation, fec_blocks, ti_blocks, carrier_mode, fft_size, guard_interval, l1_constellation, pilot_pattern, 2, data_symbols, papr_mode, version, mode, input_mode, dvbt2.RESERVED_OFF, dvbt2.L1_SCRAMBLED_OFF, dvbt2.INBAND_OFF) dvbt2_freqinterleaver = dvbt2.freqinterleaver_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode) dvbt2_pilotgenerator = dvbt2.pilotgenerator_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, mode, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_ON, equalization_bandwidth, fftsize) dvbt2_paprtr = dvbt2.paprtr_cc(carrier_mode, fft_size, pilot_pattern, guard_interval, data_symbols, papr_mode, version, papr_vclip, papr_iterations, fftsize) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(fftsize, fftsize+(gi), 0, "") dvbt2_p1insertion = dvbt2.p1insertion_cc(carrier_mode, fft_size, guard_interval, data_symbols, mode, dvbt2.SHOWLEVELS_OFF, 3.31) blocks_multiply_const = blocks.multiply_const_vcc((0.2, )) log.debug("DVB-T2 blocks initialized") out = osmosdr.sink(args="numchan=1") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bb_gain(bb_gain, 0) out.set_antenna("", 0) out.set_bandwidth(bandwidth, 0) log.debug("Output block initialized")
def __init__(self, dab_params, verbose=False, debug=False): """ Hierarchical block for OFDM modulation @param dab_params DAB parameter object (dab.parameters.dab_parameters) @param debug enables debug output to files """ dp = dab_params gr.hier_block2.__init__(self,"ofdm_mod", gr.io_signature2(2, 2, gr.sizeof_char*dp.num_carriers/4, gr.sizeof_char), # input signature gr.io_signature (1, 1, gr.sizeof_gr_complex)) # output signature # symbol mapping self.mapper = dab.qpsk_mapper_vbc(dp.num_carriers) # add pilot symbol self.insert_pilot = dab.ofdm_insert_pilot_vcc(dp.prn) # phase sum self.sum_phase = dab.sum_phasor_trig_vcc(dp.num_carriers) # frequency interleaving self.interleave = dab.frequency_interleaver_vcc(dp.frequency_interleaving_sequence_array) # add central carrier & move to middle self.move_and_insert_carrier = dab.ofdm_move_and_insert_zero(dp.fft_length, dp.num_carriers) # ifft self.ifft = fft.fft_vcc(dp.fft_length, False, [], True) # cyclic prefixer self.prefixer = digital.ofdm_cyclic_prefixer(dp.fft_length, dp.symbol_length) # convert back to vectors self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, dp.symbol_length) # add null symbol self.insert_null = dab.insert_null_symbol(dp.ns_length, dp.symbol_length) # # connect it all # # data self.connect((self,0), self.mapper, (self.insert_pilot,0), (self.sum_phase,0), self.interleave, self.move_and_insert_carrier, self.ifft, self.prefixer, self.s2v, (self.insert_null,0)) self.connect(self.insert_null, self) # control signal (frame start) self.connect((self,1), (self.insert_pilot,1), (self.sum_phase,1), (self.insert_null,1)) if debug: self.connect(self.mapper, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_mapper.dat")) self.connect(self.insert_pilot, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_insert_pilot.dat")) self.connect(self.sum_phase, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_sum_phase.dat")) self.connect(self.interleave, blocks.file_sink(gr.sizeof_gr_complex*dp.num_carriers, "debug/generated_signal_interleave.dat")) self.connect(self.move_and_insert_carrier, blocks.file_sink(gr.sizeof_gr_complex*dp.fft_length, "debug/generated_signal_move_and_insert_carrier.dat")) self.connect(self.ifft, blocks.file_sink(gr.sizeof_gr_complex*dp.fft_length, "debug/generated_signal_ifft.dat")) self.connect(self.prefixer, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal_prefixer.dat")) self.connect(self.insert_null, blocks.file_sink(gr.sizeof_gr_complex, "debug/generated_signal.dat"))
def __init__(self): gr.top_block.__init__(self, "Simulator Ofdm") Qt.QWidget.__init__(self) self.setWindowTitle("Simulator Ofdm") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "simulator_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5000000 self.packet_len = packet_len = 2**9 self.occupied_carriers_all = occupied_carriers_all = (range(-26, 27), ) self.fft_len = fft_len = 2**6 self.zeropadding_fac = zeropadding_fac = 2 self.velocity = velocity = 500 self.value_range = value_range = 100 self.v_max = v_max = 2000 self.transpose_len = transpose_len = int( np.ceil(packet_len * 4.0 / len(occupied_carriers_all[0]))) self.sync_word2 = sync_word2 = [ 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0 ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.pilot_symbols = pilot_symbols = (( 1, 1, 1, -1, ), ) self.pilot_carriers = pilot_carriers = (( -21, -7, 7, 21, ), ) self.payload_mod = payload_mod = digital.constellation_qpsk() self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.length_tag_key = length_tag_key = "packet_len" self.discarded_carriers = discarded_carriers = [] self.center_freq = center_freq = 2.45e9 self.R_max = R_max = 3e8 / 2 / samp_rate * fft_len ################################################## # Blocks ################################################## self._velocity_range = Range(-v_max, v_max, 1, 500, 200) self._velocity_win = RangeWidget(self._velocity_range, self.set_velocity, 'Velocity', "counter_slider", float) self.top_grid_layout.addWidget(self._velocity_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._value_range_range = Range(0.1, R_max, 1, 100, 200) self._value_range_win = RangeWidget(self._value_range_range, self.set_value_range, 'range', "counter_slider", float) self.top_grid_layout.addWidget(self._value_range_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.radar_transpose_matrix_vcvc_0_0 = radar.transpose_matrix_vcvc( transpose_len, fft_len * zeropadding_fac, "packet_len") (self.radar_transpose_matrix_vcvc_0_0).set_min_output_buffer(78) self.radar_transpose_matrix_vcvc_0 = radar.transpose_matrix_vcvc( fft_len * zeropadding_fac, transpose_len, "packet_len") (self.radar_transpose_matrix_vcvc_0).set_min_output_buffer(256) self.radar_static_target_simulator_cc_0 = radar.static_target_simulator_cc( (value_range, ), (velocity, ), (1e25, ), (0, ), (0, ), samp_rate, center_freq, -10, True, True, "packet_len") (self.radar_static_target_simulator_cc_0).set_min_output_buffer(6240) self.radar_qtgui_spectrogram_plot_0 = radar.qtgui_spectrogram_plot( fft_len * zeropadding_fac, 500, 'value_range', 'Velocity', 'OFDM Radar', (0, R_max), (0, v_max), (-15, -12), True, "packet_len") self.radar_print_results_0 = radar.print_results(False, "") self.radar_os_cfar_2d_vc_0 = radar.os_cfar_2d_vc( fft_len * zeropadding_fac, (10, 10), (0, 0), 0.78, 30, "packet_len") self.radar_ofdm_divide_vcvc_0 = radar.ofdm_divide_vcvc( fft_len, (fft_len - len(discarded_carriers)) * zeropadding_fac, (()), 0, "packet_len") (self.radar_ofdm_divide_vcvc_0).set_min_output_buffer(78) self.radar_ofdm_cyclic_prefix_remover_cvc_0 = radar.ofdm_cyclic_prefix_remover_cvc( fft_len, fft_len / 4, "packet_len") (self.radar_ofdm_cyclic_prefix_remover_cvc_0).set_min_output_buffer(78) self.radar_estimator_ofdm_0 = radar.estimator_ofdm( 'range', fft_len * zeropadding_fac, (0, R_max), 'velocity', transpose_len, (0, v_max, -v_max, 0), True) self.fft_vxx_0_1_0 = fft.fft_vcc( transpose_len, False, (window.blackmanharris(transpose_len)), False, 1) self.fft_vxx_0_1 = fft.fft_vcc( fft_len * zeropadding_fac, True, (window.blackmanharris(fft_len * zeropadding_fac)), False, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, True, (()), True, 1) (self.fft_vxx_0_0).set_min_output_buffer(78) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, 0, length_tag_key) (self.digital_ofdm_cyclic_prefixer_0).set_min_output_buffer(6240) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers_all, ((), ), ((), ), (), length_tag_key) (self.digital_ofdm_carrier_allocator_cvc_0).set_min_output_buffer(78) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc( (payload_mod.points()), 1) (self.digital_chunks_to_symbols_xx_0_0).set_min_output_buffer(4096) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( 8, payload_mod.bits_per_symbol(), length_tag_key, False, gr.GR_LSB_FIRST) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * fft_len * zeropadding_fac) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(1, fft_len * zeropadding_fac, 0) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared( fft_len * zeropadding_fac) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0.1, 0) ################################################## # Connections ################################################## self.msg_connect((self.radar_estimator_ofdm_0, 'Msg out'), (self.radar_print_results_0, 'Msg in')) self.msg_connect((self.radar_os_cfar_2d_vc_0, 'Msg out'), (self.radar_estimator_ofdm_0, 'Msg in')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.radar_ofdm_cyclic_prefix_remover_cvc_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.radar_qtgui_spectrogram_plot_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.radar_ofdm_divide_vcvc_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.radar_static_target_simulator_cc_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.radar_ofdm_divide_vcvc_0, 1)) self.connect((self.fft_vxx_0_1, 0), (self.radar_transpose_matrix_vcvc_0, 0)) self.connect((self.fft_vxx_0_1_0, 0), (self.radar_transpose_matrix_vcvc_0_0, 0)) self.connect((self.radar_ofdm_cyclic_prefix_remover_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.radar_ofdm_divide_vcvc_0, 0), (self.fft_vxx_0_1, 0)) self.connect((self.radar_static_target_simulator_cc_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.radar_transpose_matrix_vcvc_0, 0), (self.fft_vxx_0_1_0, 0)) self.connect((self.radar_transpose_matrix_vcvc_0_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.radar_transpose_matrix_vcvc_0_0, 0), (self.radar_os_cfar_2d_vc_0, 0))
def __init__(self, filename="tx-test.32fc"): grc_wxgui.top_block_gui.__init__(self, title="SWiFi TX") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.filename = filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 self.mult = mult = 1 self.lo_offset = lo_offset = 0 self.gain = gain = 25 self.freq = freq = 2.462e9 self.encoding = encoding = 3 ################################################## # Blocks ################################################## _mult_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, label='mult', converter=forms.float_converter(), proportion=0, ) self._mult_slider = forms.slider( parent=self.GetWin(), sizer=_mult_sizer, value=self.mult, callback=self.set_mult, minimum=0, maximum=2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_sizer) self.swifi_wifi_conv_encoder_0 = swifi.wifi_conv_encoder("phy") self.swifi_scrambler_0_0 = swifi.scrambler(True, "phy") self.swifi_sample_adder_0 = swifi.sample_adder(100, 11, 320) self.swifi_phy_frame_generator_0 = swifi.phy_frame_generator( "phy", "packet_len") self.swifi_mac_frame_generator_0 = swifi.mac_frame_generator( "phy", 11, 100) self.swifi_interleaver_0_0 = swifi.interleaver(True, "phy") self.swifi_chunks_to_symbols_0_0 = swifi.chunks_to_symbols("phy") self.swifi_bit_stealer_0_0 = swifi.bit_stealer("phy") self.swifi_bit_packer_0_0 = swifi.bit_packer("phy", 1) self._samp_rate_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.samp_rate, callback=self.set_samp_rate, label="Sample Rate", choices=[10e6, 20e6], labels=["10 Mhz", "20 Mhz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self._lo_offset_chooser = forms.drop_down( parent=self.GetWin(), value=self.lo_offset, callback=self.set_lo_offset, label="LO Offset", choices=[0, 6e9, 11e9], labels=['0 MHz', '6 MHz', '11 MHz'], ) self.Add(self._lo_offset_chooser) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_gain_sizer) self._freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.freq, callback=self.set_freq, label="Channel", choices=[ 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, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ], 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', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '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.Add(self._freq_chooser) self.fft_vxx_0_0 = fft.fft_vcc(64, False, (tuple([1.0 / 64] * 64)), True, 1) self._encoding_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.encoding, callback=self.set_encoding, label="Encoding", choices=[0, 1, 2, 3, 4, 5, 6, 7], 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" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer( 64, 64 + 16, 2, "") (self.digital_ofdm_cyclic_prefixer_0_0).set_min_output_buffer(100000) self.digital_ofdm_carrier_allocator_cvc_0_0_0 = digital.ofdm_carrier_allocator_cvc( 64, (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ), ((-21, -7, 7, 21), ), ((1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (1, 1, 1, -1), (1, 1, 1, -1), (1, 1, 1, -1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1), (-1, -1, -1, 1)), ((0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (-1.4719601443879746 - 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, (1.4719601443879746 + 1.4719601443879746j), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), (0, 0j, 0, 0j, 0, 0j, -1, 1j, -1, 1j, -1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, (-0 - 1j), 1, -1j, -1, 1j, 0, -1j, 1, (-0 - 1j), 1, -1j, 1, 1j, -1, -1j, 1, (-0 - 1j), -1, 1j, 1, 1j, 1, 1j, 1, 1j, -1, -1j, 1, 1j, 1, -1j, -1, 0j, 0, 0j, 0, 0j), (0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 1, -1, -1, 1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 0, 0, 0, 0, 0)), "packet_len") (self.digital_ofdm_carrier_allocator_cvc_0_0_0 ).set_min_output_buffer(10000) self.blocks_vector_source_x_1 = blocks.vector_source_b([ ord(x) for x in tuple( "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" ) ], False, 1, []) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, )) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, filename, False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.swifi_sample_adder_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.swifi_scrambler_0_0, 0)) self.connect((self.blocks_vector_source_x_1, 0), (self.swifi_mac_frame_generator_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0)) self.connect((self.swifi_bit_packer_0_0, 0), (self.swifi_chunks_to_symbols_0_0, 0)) self.connect((self.swifi_bit_stealer_0_0, 0), (self.swifi_interleaver_0_0, 0)) self.connect((self.swifi_chunks_to_symbols_0_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0_0_0, 0)) self.connect((self.swifi_interleaver_0_0, 0), (self.swifi_bit_packer_0_0, 0)) self.connect((self.swifi_mac_frame_generator_0, 0), (self.swifi_phy_frame_generator_0, 0)) self.connect((self.swifi_phy_frame_generator_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.swifi_sample_adder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.swifi_scrambler_0_0, 0), (self.swifi_wifi_conv_encoder_0, 0)) self.connect((self.swifi_wifi_conv_encoder_0, 0), (self.swifi_bit_stealer_0_0, 0))
def test_wo_tags_2s_rolloff_multiple_cps(self): "Two CP lengths, 2-sample rolloff and no tags." fft_len = 8 cp_lengths = (3, 2, 2) rolloff = 2 expected_result = [ 6.0 / 2, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 1 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 2 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 3 6.0 / 2 + 1.0 / 2, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8, # 4 7.0 / 2 + 1.0 / 2, 8, 1, 2, 3, 4, 5, 6, 7, 8 # 5 ] src = blocks.vector_source_c( list(range(1, fft_len + 1)) * 5, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, cp_lengths, rolloff) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def __init__(self, center_freq, sbx_db_tx_gain, sbx_db_rx_gain, bb_ampl, dir_filename1, dir_filename2): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.TxParams = TxParams = struct({ 'NFFT': 2048, 'UsedSC': 1680, 'CPlen': 512, 'Ovx': 6, 'N': 5000, 'SampRate': 100e6 / 50.0, 'CenterFreq': center_freq }) self.lo_offset = lo_offset = 3.0 * TxParams.SampRate ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(TxParams.SampRate) self.uhd_usrp_source_0.set_center_freq(TxParams.CenterFreq, 0) self.uhd_usrp_source_0.set_gain(sbx_db_rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(TxParams.SampRate) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(TxParams.CenterFreq, rf_freq=(TxParams.CenterFreq + lo_offset), rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_gain(sbx_db_tx_gain, 0) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=TxParams.SampRate, fft_size=8192, ref_scale=2, frame_rate=30, avg_alpha=1.0, average=False, ) self.dpd_Agilent_N1996A_0 = dpd.Agilent_N1996A('169.254.251.20', TxParams.CenterFreq, TxParams.SampRate, 5.1e3, 1001) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_float * 8192, dir_filename2, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 4096, dir_filename1, False) self.blocks_file_sink_0.set_unbuffered(False) self.hier_dpd_elliptic_filter_0 = hier_dpd_elliptic_filter() self.dpd_upsample_0 = dpd.upsample(ovx=TxParams.Ovx, ) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( TxParams.NFFT, (TxParams.NFFT + TxParams.CPlen), 32, '') self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (bb_ampl, )) self.basic_qpskofdm_tx_withoutCP_0 = dpd.basic_qpskofdm_tx_withoutCP( N=TxParams.N, NFFT=TxParams.NFFT, used_sc=TxParams.UsedSC, syms_filename='/tmp/qpsk_syms.bin') ################################################## # Connections ################################################## self.connect((self.basic_qpskofdm_tx_withoutCP_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.dpd_upsample_0, 0)) self.connect((self.dpd_upsample_0, 0), (self.hier_dpd_elliptic_filter_0, 0)) self.connect((self.hier_dpd_elliptic_filter_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.dpd_Agilent_N1996A_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))
def main(args): nargs = len(args) if nargs == 1: infile = args[0] outfile = None elif nargs == 2: infile = args[0] outfile = args[1] else: sys.stderr.write("Usage: dvbt-hackrf.py infile [output_file]\n"); sys.exit(1) ## Config Options config = DVBTConfig('dvbt.conf') # DVB-T Parameters channel_mhz = config.get_channel_mhz() mode = config.get_mode() code_rate = config.get_code_rate() constellation = config.get_constellation() guard_interval = config.get_guard_interval() # Hack-RF Parameters center_freq = config.get_center_freq() rf_gain = config.get_hackrf_rf_gain() if_gain = config.get_hackrf_if_gain() bb_gain = config.get_hackrf_bb_gain() ## samp_rate = 10000000.0 if mode == dvbt.T2k: factor = 1 carriers = 2048 elif mode == dvbt.T8k: factor = 4 carriers = 8192 if guard_interval == dvbt.G1_32: gi = carriers / 32 elif guard_interval == dvbt.G1_16: gi = carriers / 16 elif guard_interval == dvbt.G1_8: gi = carriers / 8 elif guard_interval == dvbt.G1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 log=gr.logger("dvbt-hackrf") log.set_level("DEBUG"); log.debug("logger initilized") tb = gr.top_block() log.debug("top block initialized") src = blocks.file_source(gr.sizeof_char, infile, True) log.debug("source block initialized") dvbt_energy_dispersal = dvbt.energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dvbt.reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dvbt.convolutional_interleaver((136 * factor), 12, 17) dvbt_inner_coder = dvbt.inner_coder(1, (1512 * factor), constellation, dvbt.NH, code_rate) dvbt_bit_inner_interleaver = dvbt.bit_inner_interleaver((1512 * factor), constellation, dvbt.NH, mode) dvbt_symbol_inner_interleaver = dvbt.symbol_inner_interleaver((1512 * factor), mode, 1) dvbt_dvbt_map = dvbt.dvbt_map((1512 * factor), constellation, dvbt.NH, mode, 1) dvbt_reference_signals = dvbt.reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dvbt.NH, code_rate, code_rate, dvbt.G1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "") rational_resampler_xxx = filter.rational_resampler_ccc(interpolation=70, decimation=64, taps=None, fractional_bw=None) blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087, )) log.debug("DVB-T blocks initialized") out = osmosdr.sink(args="numchan=1") out.set_sample_rate(samp_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bb_gain(bb_gain, 0) out.set_antenna("", 0) out.set_bandwidth(0, 0) log.debug("Output block initialized") tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_dvbt_map) tb.connect(dvbt_dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, rational_resampler_xxx) tb.connect(rational_resampler_xxx, out) log.debug("all blocks connected") if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) log.debug("running gnuradio") tb.run()
def __init__(self): gr.top_block.__init__(self, "Dvbt Tx") ################################################## # Variables ################################################## self._bandwidth_config = ConfigParser.ConfigParser() self._bandwidth_config.read('./dvbt.conf') try: bandwidth = self._bandwidth_config.getint('dvbt', 'bandwidth') except: bandwidth = 8000000 self.bandwidth = bandwidth self.samp_rate = samp_rate = (bandwidth / 7) * 8 self._rf_gain_config = ConfigParser.ConfigParser() self._rf_gain_config.read('./dvbt.conf') try: rf_gain = self._rf_gain_config.getint('hackrf', 'rf_gain') except: rf_gain = 0 self.rf_gain = rf_gain self._mode_config = ConfigParser.ConfigParser() self._mode_config.read('./dvbt.conf') try: mode = self._mode_config.get('dvbt', 'mode') except: mode = 0 self.mode = mode self._if_gain_config = ConfigParser.ConfigParser() self._if_gain_config.read('./dvbt.conf') try: if_gain = self._if_gain_config.getint('hackrf', 'if_gain') except: if_gain = 0 self.if_gain = if_gain self._guard_interval_config = ConfigParser.ConfigParser() self._guard_interval_config.read('./dvbt.conf') try: guard_interval = self._guard_interval_config.get( 'dvbt', 'guard_interval') except: guard_interval = 0 self.guard_interval = guard_interval self._frequency_config = ConfigParser.ConfigParser() self._frequency_config.read('./dvbt.conf') try: frequency = self._frequency_config.getint('hackrf', 'frequency') except: frequency = 858000000 self.frequency = frequency self._constellation_config = ConfigParser.ConfigParser() self._constellation_config.read('./dvbt.conf') try: constellation = self._constellation_config.get( 'dvbt', 'constellation') except: constellation = 0 self.constellation = constellation self._coderate_config = ConfigParser.ConfigParser() self._coderate_config.read('./dvbt.conf') try: coderate = self._coderate_config.get('dvbt', 'coderate') except: coderate = 0 self.coderate = coderate infile = str(sys.argv[1]) #Constellation QPSK 16QAM 64QAM if constellation == "QPSK": const = dtv.MOD_QPSK elif constellation == "16QAM": const = dtv.MOD_16QAM elif constellation == "64QAM": const = dtv.MOD_64QAM else: sys.stderr.write( "CONSTELLATION IN CONFIG WRONG! Values: QPSK, 16QAM or 64QAM \n" ) sys.exit(1) # Coderate 1/2 2/3 3/4 5/6 7/8 if coderate == "1/2": codr = dtv.C1_2 elif coderate == "2/3": codr = dtv.C2_3 elif coderate == "3/4": codr = dtv.C3_4 elif coderate == "5/6": codr = dtv.C5_6 elif coderate == "7/8": codr = dtv.C7_8 else: sys.stderr.write( "CODERATE IN CONFIG WRONG! Values: 1/2, 2/3, 3/4, 5/6 or 7/8 \n" ) sys.exit(1) if mode == "2k": factor = 1 carriers = 2048 modus = dtv.T2k elif mode == "8k": factor = 4 carriers = 8192 modus = dtv.T8k else: sys.stderr.write("MODE IN CONFIG WRONG! Values: 2k or 8k \n") sys.exit(1) #guard_interval dtv.GI_1_32 1/4 1/8 1/16 1/32 if guard_interval == "1/4": guardi = dtv.GI_1_4 gi = carriers / 4 elif guard_interval == "1/8": guardi = dtv.GI_1_8 gi = carriers / 8 elif guard_interval == "1/16": guardi = dtv.GI_1_16 gi = carriers / 16 elif guard_interval == "1/32": guardi = dtv.GI_1_32 gi = carriers / 32 else: sys.stderr.write( "GUARD_INTERVAL IN CONFIG WRONG! Values: 1/4, 1/8, 1/16 or 1/32 \n" ) sys.exit(1) ################################################## # 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(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 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(carriers, False, (window.rectangular(carriers)), True, 1) self.dtv_dvbt_symbol_inner_interleaver_0 = dtv.dvbt_symbol_inner_interleaver( (1512 * factor), modus, 1) self.dtv_dvbt_reference_signals_0 = dtv.dvbt_reference_signals( gr.sizeof_gr_complex, (1512 * factor), carriers, const, dtv.NH, codr, codr, guardi, modus, 1, 0) self.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) self.dtv_dvbt_map_0 = dtv.dvbt_map((1512 * factor), const, dtv.NH, modus, 1) self.dtv_dvbt_inner_coder_0 = dtv.dvbt_inner_coder( 1, (1512 * factor), const, dtv.NH, codr) self.dtv_dvbt_energy_dispersal_0 = dtv.dvbt_energy_dispersal(1 * factor) self.dtv_dvbt_convolutional_interleaver_0 = dtv.dvbt_convolutional_interleaver( (136 * factor), 12, 17) self.dtv_dvbt_bit_inner_interleaver_0 = dtv.dvbt_bit_inner_interleaver( (1512 * factor), const, dtv.NH, modus) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( carriers, carriers + (gi), 0, '') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (0.0022097087, )) if infile == "-": self.blocks_file_descriptor_source_0 = blocks.file_descriptor_source( gr.sizeof_char * 1, 0, True) else: self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, infile, True) ################################################## # Connections ################################################## if infile == "-": self.connect((self.blocks_file_descriptor_source_0, 0), (self.dtv_dvbt_energy_dispersal_0, 0)) else: self.connect((self.blocks_file_source_0, 0), (self.dtv_dvbt_energy_dispersal_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.blocks_multiply_const_vxx_0, 0)) self.connect((self.dtv_dvbt_bit_inner_interleaver_0, 0), (self.dtv_dvbt_symbol_inner_interleaver_0, 0)) self.connect((self.dtv_dvbt_convolutional_interleaver_0, 0), (self.dtv_dvbt_inner_coder_0, 0)) self.connect((self.dtv_dvbt_energy_dispersal_0, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.dtv_dvbt_inner_coder_0, 0), (self.dtv_dvbt_bit_inner_interleaver_0, 0)) self.connect((self.dtv_dvbt_map_0, 0), (self.dtv_dvbt_reference_signals_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.dtv_dvbt_convolutional_interleaver_0, 0)) self.connect((self.dtv_dvbt_reference_signals_0, 0), (self.fft_vxx_0, 0)) self.connect((self.dtv_dvbt_symbol_inner_interleaver_0, 0), (self.dtv_dvbt_map_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_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 = 32000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=1200e6, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=10e6, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=70, decimation=64, taps=None, fractional_bw=None, ) 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_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 2048) 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) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "testBB.bin", False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # 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.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink2_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.blocks_vector_to_stream_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.blocks_file_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.wxgui_fftsink2_0, 0))
def test_wo_tags_no_rolloff_multiple_cps(self): "Two CP lengths, no rolloff and no tags." fft_len = 8 cp_lengths = (3, 2, 2) expected_result = [ 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, # 1 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, # 2 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, # 3 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, # 4 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, # 5 ] src = blocks.vector_source_c(list(range(fft_len)) * 5, False, fft_len) cp = digital.ofdm_cyclic_prefixer(fft_len, cp_lengths) sink = blocks.vector_sink_c() self.tb.connect(src, cp, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def main(args): d = 'Transmit a DVB-T signal using the bladeRF and gr-dtv' parser = argparse.ArgumentParser() mode_help = '# of carriers. Options: t2k, t8k (default).' parser.add_argument('-m', '--mode', dest='mode', default='t8k', type=str, help=mode_help) ch_help = 'channel width in MHz. Options: 5, 6, 7, 8 (default).' parser.add_argument('-c', '--channel', dest='channel', default=8, metavar='CH', type=int, help=ch_help) const_help = 'constellation. qpsk, qam16, qam64 (default).' parser.add_argument('-C', '--cons', dest='cons', default='qam64', metavar='TYPE', type=str, help=const_help) rate_help = 'Viterbi rate. 1/2, 2/3, 3/4, 5/6, 7/8 (default).' parser.add_argument('-r', '--rate', dest='rate', default='7/8', type=str, help=rate_help) guard_help = 'guard interval. 1/32 (default), 1/16, 1/8, 1/4.' parser.add_argument('-g', '--guard', dest='interval', default='1/32', metavar='D', type=str, help=guard_help) freq_help = 'center frequency (Hz). Default is 429e6.' parser.add_argument('-f', '--freq', dest='freq', default=429e6, type=float, help=freq_help) vga1_help = 'bladeRF TXVGA1 gain. Default is -6.' parser.add_argument('--txvga1', dest='txvga1', default=-6, metavar='gain', type=int, help=vga1_help) vga2_help = 'bladeRF TXVGA2 gain. Default is 9.' parser.add_argument('--txvga2', dest='txvga2', default=9, metavar='gain', type=int, help=vga2_help) outfile_help = 'write to specified file.' parser.add_argument('-o', '--output', dest='outfile', default=None, metavar='OUT', type=str, help=outfile_help) parser.add_argument('infile', metavar='input-file', type=str, help='Input file') args = parser.parse_args() print args if args.mode.lower() == 't2k': mode = dtv.T2k elif args.mode.lower() == 't8k': mode = dtv.T8k else: sys.stderr.write('Invalid mode provided: ' + args.mode + '\n') sys.exit(1) if args.channel < 5 or args.channel > 8: sys.stderr.write('Invalid channel: ' + str(args.channel) + '\n') sys.exit(1) else: channel_mhz = args.channel if args.cons.lower() == 'qpsk': constellation = dtv.MOD_QPSK elif args.cons.lower() == 'qam16': constellation = dtv.MOD_16QAM elif args.cons.lower() == 'qam64': constellation = dtv.MOD_64QAM else: sys.stderr.write('Invalid constellation type: ' + args.cons + '\n') sys.exit(1) if args.rate == '1/2': code_rate = dtv.C1_2 elif args.rate == '2/3': code_rate = dtv.C2_3 elif args.rate == '3/4': code_rate = dtv.C3_4 elif args.rate == '5/6': code_rate = dtv.C5_6 elif args.rate == '7/8': code_rate = dtv.C7_8 else: sys.stderr.write('Invalid Viterbi rate: ' + args.rate + '\n') sys.exit(1) if args.interval == '1/32': guard_interval = dtv.GI_1_32 elif args.interval == '1/16': guard_interval = dtv.GI_1_16 elif args.interval == '1/8': guard_interval = dtv.GI_1_8 elif args.interval == '1/4': guard_interval = dtv.GI_1_4 else: sys.stderr.write('Invalid guard interval: ' + args.interval + '\n') sys.exit(1) if args.freq < 300e6 or args.freq > 3.8e9: sys.stderr.write('Invalid center frequency: ' + str(args.freq) + '\n') sys.exit(1) else: center_freq = int(args.freq) if args.txvga1 < -35 or args.txvga1 > -4: sys.stderr.write('Invalid bladeRF TXVGA1 gain: ' + str(args.txvga1) + '\n') sys.exit(1) else: txvga1_gain = args.txvga1 if args.txvga2 < 0 or args.txvga2 > 25: sys.stderr.write('Invalid bladeRF TXVGA2 gain: ' + str(args.txvga2) + '\n') sys.exit(1) else: txvga2_gain = args.txvga2 infile = args.infile outfile = args.outfile symbol_rate = channel_mhz * 8000000.0 / 7 if mode == dtv.T2k: factor = 1 carriers = 2048 elif mode == dtv.T8k: factor = 4 carriers = 8192 if guard_interval == dtv.GI_1_32: gi = carriers / 32 elif guard_interval == dtv.GI_1_16: gi = carriers / 16 elif guard_interval == dtv.GI_1_8: gi = carriers / 8 elif guard_interval == dtv.GI_1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = blocks.file_source(gr.sizeof_char, infile, True) dtv_dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor) dtv_dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dtv_dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver( (136 * factor), 12, 17) dtv_dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate) dtv_dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver( (1512 * factor), constellation, dtv.NH, mode) dtv_dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver( (1512 * factor), mode, 1) dtv_dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1) dtv_dvbt_reference_signals = dtv.dvbt_reference_signals( gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, guard_interval, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( carriers, carriers + (gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087, )) out = osmosdr.sink(args="bladerf=0,buffers=128,buflen=32768") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(txvga2_gain, 0) out.set_bb_gain(txvga1_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dtv_dvbt_energy_dispersal) tb.connect(dtv_dvbt_energy_dispersal, dtv_dvbt_reed_solomon_enc) tb.connect(dtv_dvbt_reed_solomon_enc, dtv_dvbt_convolutional_interleaver) tb.connect(dtv_dvbt_convolutional_interleaver, dtv_dvbt_inner_coder) tb.connect(dtv_dvbt_inner_coder, dtv_dvbt_bit_inner_interleaver) tb.connect(dtv_dvbt_bit_inner_interleaver, dtv_dvbt_symbol_inner_interleaver) tb.connect(dtv_dvbt_symbol_inner_interleaver, dtv_dvbt_map) tb.connect(dtv_dvbt_map, dtv_dvbt_reference_signals) tb.connect(dtv_dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
def __init__(self,DRMParameters): gr.top_block.__init__(self, "DRM Transmitter 1") ################################################## # Variables ################################################## self.text_message = text_message = DRMParameters.text_msg self.station_label = station_label = DRMParameters.station_label self.msc_prot_level_2 = msc_prot_level_2 = 1 self.long_interl = long_interl = True self.audio_sample_rate = audio_sample_rate = DRMParameters.audio_samp*1000 self.SO = SO = DRMParameters.so self.RM = RM = DRMParameters.rm self.tp = tp = drm.transm_params(RM, SO, False, 0, False, DRMParameters.msc_mod, 0, msc_prot_level_2, DRMParameters.sdc_mod, 0, long_interl, audio_sample_rate, station_label, text_message) self.samp_rate = samp_rate = 48e3 self.usrp_addr = DRMParameters.usrp_id self.output_name = DRMParameters.output_name self.center_freq = DRMParameters.center_freq*1e6 self.audio_file = DRMParameters.audio_file ################################################## # Blocks ################################################## if DRMParameters.uhd_found: self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((self.usrp_addr, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate * 250 / 48) self.uhd_usrp_sink_0.set_center_freq(self.center_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TXA", 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.fft_vxx_0 = fft.fft_vcc(tp.ofdm().nfft(), False, (), True, 1) self.drm_scrambler_bb_0_1 = drm.scrambler_bb(tp.sdc().L()) self.drm_scrambler_bb_0_0 = drm.scrambler_bb(tp.fac().L()) self.drm_scrambler_bb_0 = drm.scrambler_bb(tp.msc().L_MUX()) self.drm_mlc_4qam_bc_0_0 = drm_mlc_4qam_bc( bits_per_symbol=tp.fac().mod_order(), denom_mother_code_rate=drm.DENOM_MOTHER_CODE, gen_poly=(91, 121, 101, 91, 121, 101), interl_seq=tp.fac().bit_interl_seq_0_2(), map_tab=tp.cfg().ptables().d_QAM4, n_tailbits=drm.N_TAILBITS / drm.DENOM_MOTHER_CODE, pp=tp.fac().punct_pat_0(), pp_tail=tp.fac().punct_pat_0(), vlen_in=tp.fac().L(), vlen_out=tp.fac().N(), ) #SDC Configuration if DRMParameters.sdc_mod == 0: self.drm_mlc_sdc_bc= drm_mlc_16qam_bc( vlen_in=tp.sdc().L(), vlen_out=tp.sdc().N(), n_tailbits=drm.N_TAILBITS / drm.DENOM_MOTHER_CODE, denom_mother_code_rate=drm.DENOM_MOTHER_CODE, gen_poly=(91, 121, 101, 91, 121, 101), bits_per_symbol=tp.sdc().mod_order(), map_tab=tp.cfg().ptables().d_QAM16, pp_0=tp.sdc().punct_pat_0(), interl_seq_0_2=tp.sdc().bit_interl_seq_0_2(), interl_seq_1_2=tp.sdc().bit_interl_seq_1_2(), pp_1_tail=tp.sdc().punct_pat_tail_1(), pp_1=tp.sdc().punct_pat_1(), pp_0_tail=tp.sdc().punct_pat_tail_0(), M_total=tp.sdc().M_total(), part_len_top=tp.sdc().M_total()[0], part_len_bot=tp.sdc().M_total()[1], ) else: self.drm_mlc_sdc_bc = drm_mlc_4qam_bc( vlen_in=tp.sdc().L(), vlen_out=tp.sdc().N(), n_tailbits=drm.N_TAILBITS / drm.DENOM_MOTHER_CODE, denom_mother_code_rate=drm.DENOM_MOTHER_CODE, map_tab=tp.cfg().ptables().d_QAM4, interl_seq=tp.sdc().bit_interl_seq_0_2(), bits_per_symbol=tp.sdc().mod_order(), pp=tp.sdc().punct_pat_0(), pp_tail=tp.sdc().punct_pat_tail_0(), gen_poly=(91, 121, 101, 91, 121, 101), ) #MSC Configuration if DRMParameters.msc_mod == 2: self.drm_mlc_msc_bc = drm_mlc_64qam_sm_bc( vlen_in=tp.msc().L_MUX(), n_tailbits=drm.N_TAILBITS / drm.DENOM_MOTHER_CODE, denom_mother_code_rate=drm.DENOM_MOTHER_CODE, gen_poly=(91, 121, 101, 91, 121, 101), vlen_out=tp.msc().N_MUX(), bits_per_symbol=tp.msc().mod_order(), map_tab=tp.cfg().ptables().d_QAM64SM, pp_0=tp.msc().punct_pat_0_2(), pp_0_tail=tp.msc().punct_pat_tail_0_2(), pp_1=tp.msc().punct_pat_1_2(), pp_1_tail=tp.msc().punct_pat_tail_1_2(), pp_2=tp.msc().punct_pat_2_2(), pp_2_tail=tp.msc().punct_pat_tail_2_2(), interl_seq_0_2=tp.msc().bit_interl_seq_0_2(), interl_seq_2_2=tp.msc().bit_interl_seq_2_2(), interl_seq_1_2=tp.msc().bit_interl_seq_1_2(), M_total=tp.msc().M_total(), part_len_bot=tp.msc().M_total()[2], part_len_top=tp.msc().M_total()[0], part_len_mid=tp.msc().M_total()[1], ) else: self.drm_mlc_msc_bc = drm_mlc_16qam_bc( vlen_in=tp.msc().L_MUX(), vlen_out=tp.msc().N_MUX(), n_tailbits=drm.N_TAILBITS / drm.DENOM_MOTHER_CODE, denom_mother_code_rate=drm.DENOM_MOTHER_CODE, gen_poly=(91, 121, 101, 91, 121, 101), bits_per_symbol=tp.msc().mod_order(), map_tab=tp.cfg().ptables().d_QAM16, pp_0=tp.msc().punct_pat_0_2(), interl_seq_0_2=tp.msc().bit_interl_seq_0_2(), interl_seq_1_2=tp.msc().bit_interl_seq_1_2(), pp_1_tail=tp.msc().punct_pat_tail_1_2(), pp_1=tp.msc().punct_pat_1_2(), pp_0_tail=tp.msc().punct_pat_tail_0_2(), M_total=tp.msc().M_total(), part_len_top=tp.msc().M_total()[0], part_len_bot=tp.msc().M_total()[1], ) self.drm_interleaver_cc_0 = drm.interleaver_cc((tp.msc().cell_interl_seq()), long_interl, drm.INTL_DEPTH_DRM) self.drm_generate_sdc_b_0 = drm.generate_sdc_b(tp) self.drm_generate_fac_b_0 = drm.generate_fac_b(tp) self.drm_audio_encoder_sb_0 = drm.audio_encoder_sb(tp) self.digital_ofdm_cyclic_prefixer_1 = digital.ofdm_cyclic_prefixer(tp.ofdm().nfft(), tp.ofdm().nfft()+tp.ofdm().nfft()/4, 0, "") self.cell_mapping_cc_0 = drm.cell_mapping_cc(tp, (tp.msc().N_MUX() * tp.ofdm().M_TF() * 8, tp.sdc().N() * 8, tp.fac().N() * tp.ofdm().M_TF() * 8)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) if DRMParameters.pulse_audio: self.audio_source_1 = audio.source(audio_sample_rate, "", True) else: self.blocks_wavfile_source_0 = blocks.wavfile_source(self.audio_file, False) if DRMParameters.gen_output: self.blocks_wavfile_sink_0 = blocks.wavfile_sink(self.output_name, 1, 48000, 16) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((7e-3, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((32768, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 7000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) if DRMParameters.gen_output: self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.drm_audio_encoder_sb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_0, 0)) if DRMParameters.pulse_audio: self.connect((self.audio_source_1, 0), (self.blocks_multiply_const_vxx_0, 0)) else: self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.cell_mapping_cc_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.drm_audio_encoder_sb_0, 0), (self.drm_scrambler_bb_0, 0)) self.connect((self.drm_generate_fac_b_0, 0), (self.drm_scrambler_bb_0_0, 0)) self.connect((self.drm_generate_sdc_b_0, 0), (self.drm_scrambler_bb_0_1, 0)) self.connect((self.drm_interleaver_cc_0, 0), (self.cell_mapping_cc_0, 0)) self.connect((self.drm_mlc_msc_bc, 0), (self.drm_interleaver_cc_0, 0)) self.connect((self.drm_mlc_sdc_bc, 0), (self.cell_mapping_cc_0, 1)) self.connect((self.drm_mlc_4qam_bc_0_0, 0), (self.cell_mapping_cc_0, 2)) self.connect((self.drm_scrambler_bb_0, 0), (self.drm_mlc_msc_bc, 0)) self.connect((self.drm_scrambler_bb_0_0, 0), (self.drm_mlc_4qam_bc_0_0, 0)) self.connect((self.drm_scrambler_bb_0_1, 0), (self.drm_mlc_sdc_bc, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_1, 0)) if DRMParameters.uhd_found: self.connect((self.rational_resampler_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_null_sink_0, 0))
def test_000(self): infile = ts_in_file outfile = "vv.cfile" testfile = complex_out_file file_source = blocks.file_source(gr.sizeof_char*1, infile, False, 0, 0) file_source.set_begin_tag(pmt.PMT_NIL) bbheader = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.RO_0_35, dtv.INPUTMODE_NORMAL, dtv.INBAND_OFF, 168, 4000000) bbscrambler = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3) bch = dtv.dvb_bch_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3) ldpc = dtv.dvb_ldpc_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_OTHER) interleaver = dtv.dvbt2_interleaver_bb( dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_64QAM) modulator = dtv.dvbt2_modulator_bc( dtv.FECFRAME_NORMAL, dtv.MOD_64QAM, dtv.ROTATION_ON) cellinterleaver = dtv.dvbt2_cellinterleaver_cc( dtv.FECFRAME_NORMAL, dtv.MOD_64QAM, 2, 3) framemapper = dtv.dvbt2_framemapper_cc( dtv.FECFRAME_NORMAL, dtv.C2_3, dtv.MOD_64QAM, dtv.ROTATION_ON, 2, 3, dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.GI_1_32, dtv.L1_MOD_16QAM, dtv.PILOT_PP7, 2, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.INPUTMODE_NORMAL, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) freqinterleaver = dtv.dvbt2_freqinterleaver_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO ) pilotgenerator = dtv.dvbt2_pilotgenerator_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, dtv.PREAMBLE_T2_SISO, dtv.MISO_TX1, dtv.EQUALIZATION_OFF, dtv.BANDWIDTH_8_0_MHZ, 4096 ) paprtr = dtv.dvbt2_paprtr_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.PILOT_PP7, dtv.GI_1_32, 7, dtv.PAPR_TR, dtv.VERSION_111, 3.0, 10, 4096 ) ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( 4096, 4096 + 4096 // 32, 0, '') p1insertion = dtv.dvbt2_p1insertion_cc( dtv.CARRIERS_NORMAL, dtv.FFTSIZE_4K, dtv.GI_1_32, 7, dtv.PREAMBLE_T2_SISO, dtv.SHOWLEVELS_OFF, 3.01 ) file_sink = blocks.file_sink(gr.sizeof_gr_complex*1, outfile, False) file_sink.set_unbuffered(True) self.tb.connect( file_source, bbheader, bbscrambler, bch, ldpc, interleaver, modulator, cellinterleaver, framemapper, freqinterleaver, pilotgenerator, paprtr, ofdm_cyclic_prefixer, p1insertion, file_sink) self.tb.run() file_sink.close() self.assertEqual(getsize(outfile), getsize(testfile)) out_data = np.fromfile(outfile, dtype=np.float32) expected_data = np.fromfile(testfile, dtype=np.float32) os.remove(outfile) self.assertFloatTuplesAlmostEqual(out_data, expected_data, 5) pass
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vv018 Miso") ################################################## # 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_1 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, dvbt2.MISO_TX1, dvbt2.EQUALIZATION_ON, dvbt2.BANDWIDTH_8_0_MHZ, 32768) self.dvbt2_pilotgenerator_cc_0 = dvbt2.pilotgenerator_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, dvbt2.MISO_TX2, dvbt2.EQUALIZATION_ON, dvbt2.BANDWIDTH_8_0_MHZ, 32768) self.dvbt2_p1insertion_cc_0_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, 19, dvbt2.PREAMBLE_T2_MISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_p1insertion_cc_0 = dvbt2.p1insertion_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, 19, dvbt2.PREAMBLE_T2_MISO, dvbt2.SHOWLEVELS_OFF, 3.3) self.dvbt2_modulator_bc_0 = dvbt2.modulator_bc(dvbt2.FECFRAME_NORMAL, dvbt2.MOD_256QAM, dvbt2.ROTATION_ON) self.dvbt2_miso_cc_0 = dvbt2.miso_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, ) self.dvbt2_ldpc_bb_0 = dvbt2.ldpc_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_interleaver_bb_0 = dvbt2.interleaver_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.MOD_256QAM) self.dvbt2_freqinterleaver_cc_0 = dvbt2.freqinterleaver_cc(dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.PILOT_PP2, dvbt2.GI_1_16, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, ) self.dvbt2_framemapper_cc_0 = dvbt2.framemapper_cc(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.MOD_256QAM, dvbt2.ROTATION_ON, 61, 1, dvbt2.CARRIERS_EXTENDED, dvbt2.FFTSIZE_32K, dvbt2.GI_1_16, dvbt2.L1_MOD_64QAM, dvbt2.PILOT_PP2, 2, 19, dvbt2.PAPR_OFF, dvbt2.VERSION_111, dvbt2.PREAMBLE_T2_MISO, 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_256QAM, 61, 1) self.dvbt2_bch_bb_0 = dvbt2.bch_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_bbscrambler_bb_0 = dvbt2.bbscrambler_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6) self.dvbt2_bbheader_bb_0 = dvbt2.bbheader_bb(dvbt2.FECFRAME_NORMAL, dvbt2.C5_6, dvbt2.INPUTMODE_HIEFF, dvbt2.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(32768, 32768+32768/16, 0, "") self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(32768, 32768+32768/16, 0, "") self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) 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/adv32kmiso.ts", False) ################################################## # 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.digital_ofdm_cyclic_prefixer_0_0, 0), (self.dvbt2_p1insertion_cc_0_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_miso_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_miso_cc_0, 1), (self.dvbt2_pilotgenerator_cc_0, 0)) self.connect((self.dvbt2_miso_cc_0, 0), (self.dvbt2_pilotgenerator_cc_1, 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_p1insertion_cc_0_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.dvbt2_pilotgenerator_cc_1, 0), (self.digital_ofdm_cyclic_prefixer_0_0, 0))
def __init__(self, samp_rate=10000): gr.hier_block2.__init__( self, "Sync Radio Hier Grc", 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.samp_rate = samp_rate ################################################## # Variables ################################################## self.sync_word2 = sync_word2 = [0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,(1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),(-1+0j),(1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(-1+0j),(1+0j),0j,(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),(1+0j),(1+0j),(1+0j),(1+0j),(-1+0j),0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j,0j] self.sync_word1 = sync_word1 = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,1.42,0.0,-1.42,0.0,1.42,0.0,1.42,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0] self.pilot_symbols = pilot_symbols = ((1, -1,),) self.pilot_carriers = pilot_carriers = ((-13, 12,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = ([-16, -15, -14, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 14, 15],) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = (len(sync_word1)+len(sync_word2))/2 self.rolloff = rolloff = 0 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.len_ocup_carr = len_ocup_carr = len(occupied_carriers[0]) self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=True) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.forward_OOB = forward_OOB = [0.005277622700213007, 0.03443705907448985, 0.1214101788557494, 0.29179662246081545, 0.52428014905364, 0.7350677973792328, 0.8210395030022875, 0.7350677973792348, 0.5242801490536404, 0.291796622460816, 0.1214101788557501, 0.03443705907448997, 0.005277622700213012] self.feedback_OOB = feedback_OOB = [1.0, -1.0455317889337852, 3.9201525346250072, -3.9114761684448958, 6.54266144224035, -5.737287389902878, 5.820328302284336, -4.134700802700442, 2.7949972248757664, -1.4584448495689168, 0.6358650797085171, -0.19847981428665007, 0.04200458351675313] self.cp_len = cp_len = fft_len/4 self.active_carriers = active_carriers = len(occupied_carriers[0])+4 ################################################## # Blocks ################################################## self.iir_filter_xxx_1 = filter.iir_filter_ccd((forward_OOB), (feedback_OOB), False) self.fft_vxx_txpath = fft.fft_vcc(fft_len, False, (()), True, 1) self.fft_vxx_2_rxpath = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_1_rxpath = fft.fft_vcc(fft_len, True, (()), True, 1) self.digital_packet_headerparser_b_rxpath = digital.packet_headerparser_b(header_formatter.base()) self.digital_packet_headergenerator_bb_txpath = digital.packet_headergenerator_bb(header_formatter.formatter(), "packet_len") self.digital_ofdm_sync_sc_cfb_rxpath = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False) self.digital_ofdm_serializer_vcc_payload_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, "", True) self.digital_ofdm_serializer_vcc_header_rxpath = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, "", 0, "", True) self.digital_ofdm_frame_equalizer_vcvc_2_rxpath = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), cp_len, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_1_rxpath = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), cp_len, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_txpath = digital.ofdm_cyclic_prefixer(fft_len, fft_len+cp_len, rolloff, packet_length_tag_key) (self.digital_ofdm_cyclic_prefixer_txpath).set_min_output_buffer(24000) self.digital_ofdm_chanest_vcvc_rxpath = digital.ofdm_chanest_vcvc((sync_word1), (sync_word2), 1, 0, 3, False) self.digital_ofdm_carrier_allocator_cvc_txpath = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (sync_word1, sync_word2), packet_length_tag_key) (self.digital_ofdm_carrier_allocator_cvc_txpath).set_min_output_buffer(16000) self.digital_header_payload_demux_rxpath = digital.header_payload_demux( 3, fft_len, cp_len, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), ) #self.digital_crc32_bb_txpath = digital.crc32_bb(False, packet_length_tag_key) #self.digital_crc32_bb_rxpath = digital.crc32_bb(True, packet_length_tag_key) self.digital_constellation_decoder_cb_1_rxpath = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.digital_chunks_to_symbols_x_txpath = digital.chunks_to_symbols_bc((payload_mod.points()), 1) self.digital_chunks_to_symbols_txpath = digital.chunks_to_symbols_bc((header_mod.points()), 1) self.blocks_tagged_stream_mux_txpath = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, packet_length_tag_key, 0) (self.blocks_tagged_stream_mux_txpath).set_min_output_buffer(16000) self.blocks_tag_gate_txpath = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_repack_bits_bb_txpath = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), packet_length_tag_key, False) self.blocks_repack_bits_bb_rxpath = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True) self.blocks_multiply_xx_rxpath = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.01, )) self.blocks_delay_rxpath = blocks.delay(gr.sizeof_gr_complex*1, fft_len+fft_len/4) self.analog_frequency_modulator_fc_rxpath = analog.frequency_modulator_fc(-2.0/fft_len) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 0), (self.analog_frequency_modulator_fc_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_ofdm_sync_sc_cfb_rxpath, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_delay_rxpath, 0)) self.connect((self.digital_packet_headergenerator_bb_txpath, 0), (self.digital_chunks_to_symbols_txpath, 0)) self.connect((self.blocks_repack_bits_bb_txpath, 0), (self.digital_chunks_to_symbols_x_txpath, 0)) self.connect((self.digital_chunks_to_symbols_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 0)) self.connect((self.digital_chunks_to_symbols_x_txpath, 0), (self.blocks_tagged_stream_mux_txpath, 1)) self.connect((self.digital_ofdm_cyclic_prefixer_txpath, 0), (self.blocks_tag_gate_txpath, 0)) self.connect((self.fft_vxx_txpath, 0), (self.digital_ofdm_cyclic_prefixer_txpath, 0)) self.connect((self.blocks_tagged_stream_mux_txpath, 0), (self.digital_ofdm_carrier_allocator_cvc_txpath, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_txpath, 0), (self.fft_vxx_txpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 0), (self.fft_vxx_1_rxpath, 0)) self.connect((self.fft_vxx_1_rxpath, 0), (self.digital_ofdm_chanest_vcvc_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0), (self.digital_ofdm_serializer_vcc_header_rxpath, 0)) self.connect((self.digital_ofdm_chanest_vcvc_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_1_rxpath, 0)) self.connect((self.digital_header_payload_demux_rxpath, 1), (self.fft_vxx_2_rxpath, 0)) self.connect((self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0), (self.digital_ofdm_serializer_vcc_payload_rxpath, 0)) self.connect((self.fft_vxx_2_rxpath, 0), (self.digital_ofdm_frame_equalizer_vcvc_2_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_payload_rxpath, 0), (self.digital_constellation_decoder_cb_1_rxpath, 0)) self.connect((self.digital_constellation_decoder_cb_1_rxpath, 0), (self.blocks_repack_bits_bb_rxpath, 0)) self.connect((self.digital_ofdm_serializer_vcc_header_rxpath, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_frequency_modulator_fc_rxpath, 0), (self.blocks_multiply_xx_rxpath, 0)) self.connect((self.digital_ofdm_sync_sc_cfb_rxpath, 1), (self.digital_header_payload_demux_rxpath, 1)) self.connect((self.blocks_multiply_xx_rxpath, 0), (self.digital_header_payload_demux_rxpath, 0)) self.connect((self.blocks_delay_rxpath, 0), (self.blocks_multiply_xx_rxpath, 1)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_packet_headerparser_b_rxpath, 0)) self.connect((self, 1), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_tag_gate_txpath, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.iir_filter_xxx_1, 0), (self, 1)) ''' self.connect((self, 0), (self.digital_crc32_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self.digital_crc32_bb_txpath, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self, 0), (self.blocks_repack_bits_bb_txpath, 0)) self.connect((self, 0), (self.digital_packet_headergenerator_bb_txpath, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self.digital_crc32_bb_rxpath, 0)) self.connect((self.digital_crc32_bb_rxpath, 0), (self, 0)) ''' self.connect((self.blocks_repack_bits_bb_rxpath, 0), (self, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.iir_filter_xxx_1, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.digital_packet_headerparser_b_rxpath, "header_data", self.digital_header_payload_demux_rxpath, "header_data")
def __init__(self): gr.top_block.__init__(self, "Dvbt2 Master") ################################################## # Variables ################################################## self.samp_rate = samp_rate = (8000000.0 * 8) / 7 self._rf_gain_config = ConfigParser.ConfigParser() self._rf_gain_config.read('./dvbt2.conf') try: rf_gain = self._rf_gain_config.getint('hackrf', 'rf-gain') except: rf_gain = 0 self.rf_gain = rf_gain self._if_gain_config = ConfigParser.ConfigParser() self._if_gain_config.read('./dvbt2.conf') try: if_gain = self._if_gain_config.getint('hackrf', 'if-gain') except: if_gain = 0 self.if_gain = if_gain self._center_freq_config = ConfigParser.ConfigParser() self._center_freq_config.read('./dvbt2.conf') try: center_freq = self._center_freq_config.getint( 'hackrf', 'frequency') except: center_freq = 0 self.center_freq = center_freq self._band_width_config = ConfigParser.ConfigParser() self._band_width_config.read('./dvbt2.conf') try: band_width = self._band_width_config.getint('hackrf', 'bandwidth') except: band_width = 0 self.band_width = band_width self._VERSION_config = ConfigParser.ConfigParser() self._VERSION_config.read('./dvbt2.conf') try: VERSION = self._VERSION_config.getint('dvbt2', 'version') except: VERSION = 0 self.VERSION = VERSION self._PREAMBLE_config = ConfigParser.ConfigParser() self._PREAMBLE_config.read('./dvbt2.conf') try: PREAMBLE = self._PREAMBLE_config.get('dvbt2', 'preamble') except: PREAMBLE = '0' self.PREAMBLE = PREAMBLE self._PILOT_config = ConfigParser.ConfigParser() self._PILOT_config.read('./dvbt2.conf') try: PILOT = self._PILOT_config.getint('dvbt2', 'pilot-pattern') except: PILOT = 0 self.PILOT = PILOT self._PAPR_config = ConfigParser.ConfigParser() self._PAPR_config.read('./dvbt2.conf') try: PAPR = self._PAPR_config.get('dvbt2', 'papr') except: PAPR = '0' self.PAPR = PAPR self._L1MOD_config = ConfigParser.ConfigParser() self._L1MOD_config.read('./dvbt2.conf') try: L1MOD = self._L1MOD_config.get('dvbt2', 'L1-mod') except: L1MOD = '0' self.L1MOD = L1MOD self._GI_config = ConfigParser.ConfigParser() self._GI_config.read('./dvbt2.conf') try: GI = self._GI_config.get('dvbt2', 'guard-interval') except: GI = '0' self.GI = GI self._FFTSIZE_config = ConfigParser.ConfigParser() self._FFTSIZE_config.read('./dvbt2.conf') try: FFTSIZE = self._FFTSIZE_config.get('dvbt2', 'fft-size') except: FFTSIZE = '0' self.FFTSIZE = FFTSIZE self._FECBLKS_config = ConfigParser.ConfigParser() self._FECBLKS_config.read('./dvbt2.conf') try: FECBLKS = self._FECBLKS_config.getint('dvbt2', 'fec-blocks') except: FECBLKS = 0 self.FECBLKS = FECBLKS self._DATASYM_config = ConfigParser.ConfigParser() self._DATASYM_config.read('./dvbt2.conf') try: DATASYM = self._DATASYM_config.getint('dvbt2', 'datasymbols') except: DATASYM = 0 self.DATASYM = DATASYM self._CONSTELLATION_config = ConfigParser.ConfigParser() self._CONSTELLATION_config.read('./dvbt2.conf') try: CONSTELLATION = self._CONSTELLATION_config.get( 'dvbt2', 'constellation') except: CONSTELLATION = '0' self.CONSTELLATION = CONSTELLATION self._CODERATE_config = ConfigParser.ConfigParser() self._CODERATE_config.read('./dvbt2.conf') try: CODERATE = self._CODERATE_config.get('dvbt2', 'coderate') except: CODERATE = '0' self.CODERATE = CODERATE self._CARREXT_config = ConfigParser.ConfigParser() self._CARREXT_config.read('./dvbt2.conf') try: CARREXT = self._CARREXT_config.get('dvbt2', 'ext-carriers') except: CARREXT = '0' self.CARREXT = CARREXT infile = str(sys.argv[1]) if VERSION == 111: ver = dtv.VERSION_111 elif VERSION == 131: ver = dtv.VERSION_131 else: sys.stderr.write("VERSION IN CONFIG WRONG! Values: 111 or 131 \n") sys.exit(1) if PREAMBLE == "SISO": preamb = dtv.PREAMBLE_T2_SISO elif PREAMBLE == "MISO": preamb = dtv.PREAMBLE_T2_MISO else: sys.stderr.write( "PREAMBLE IN CONFIG WRONG! Values: SISO or MISO \n") sys.exit(1) if PILOT == 1: pil = dtv.PILOT_PP1 elif PILOT == 2: pil = dtv.PILOT_PP2 elif PILOT == 3: pil = dtv.PILOT_PP3 elif PILOT == 4: pil = dtv.PILOT_PP4 elif PILOT == 5: pil = dtv.PILOT_PP5 elif PILOT == 6: pil = dtv.PILOT_PP6 elif PILOT == 7: pil = dtv.PILOT_PP7 elif PILOT == 8: pil = dtv.PILOT_PP8 else: sys.stderr.write( "PILOT-PATTERN IN CONFIG WRONG! Values: 1, 2, 3, 4, 5, 6, 7 or 8 \n" ) sys.exit(1) if PAPR == "on": pap = dtv.PAPR_ON elif PAPR == "off": pap = dtv.PAPR_OFF else: sys.stderr.write("PAPR IN CONFIG WRONG! Values: on or off \n") sys.exit(1) if L1MOD == "QPSK": l1m = dtv.L1_MOD_QPSK elif L1MOD == "BPSK": l1m = dtv.L1_MOD_BPSK elif L1MOD == "16QAM": l1m = dtv.L1_MOD_16QAM elif L1MOD == "64QAM": l1m = dtv.L1_MOD_64QAM else: sys.stderr.write( "L1-MOD IN CONFIG WRONG! Values: QPSK, BPSK, 16QAM or 64QAM \n" ) sys.exit(1) if GI == "1/32": gint = dtv.GI_1_32 mul = 1 div = 32 elif GI == "1/16": gint = dtv.GI_1_16 mul = 1 div = 16 elif GI == "1/8": gint = dtv.GI_1_8 mul = 1 div = 8 elif GI == "1/4": gint = dtv.GI_1_4 mul = 1 div = 4 elif GI == "1/128": gint = dtv.GI_1_128 mul = 1 div = 128 elif GI == "19/128": gint = dtv.GI_19_128 mul = 19 div = 128 elif GI == "19/256": gint = dtv.GI_19_256 mul = 19 div = 256 else: sys.stderr.write( "GUARD-INTERVAL IN CONFIG WRONG! Values: 1/32, 1/16, 1/8, 1/4, 1/128, 19/128, 19/256 \n" ) sys.exit(1) if FFTSIZE == "16k": ffts = dtv.FFTSIZE_16K fft_length = 16384 elif FFTSIZE == "32k": ffts = dtv.FFTSIZE_32K fft_length = 32768 else: sys.stderr.write("FFTSIZE IN CONFIG WRONG! Values: 16k or 32k \n") sys.exit(1) if CONSTELLATION == "QPSK": const = dtv.MOD_QPSK elif CONSTELLATION == "16QAM": const = dtv.MOD_16QAM elif CONSTELLATION == "64QAM": const = dtv.MOD_64QAM elif CONSTELLATION == "256QAM": const = dtv.MOD_256QAM else: sys.stderr.write( "CONSTELLATION IN CONFIG WRONG! Values: QPSK 16QAM 64QAM 256QAM \n" ) sys.exit(1) if CODERATE == "1/2": codr = dtv.C1_2 elif CODERATE == "2/5": codr = dtv.C2_5 elif CODERATE == "3/5": codr = dtv.C3_5 elif CODERATE == "2/3": codr = dtv.C2_3 elif CODERATE == "3/4": codr = dtv.C3_4 elif CODERATE == "4/5": codr = dtv.C4_5 elif CODERATE == "5/6": codr = dtv.C5_6 else: sys.stderr.write( "CODERATE IN CONFIG WRONG! Values: 1/2 2/5 3/5 2/3 3/4 4/5 5/6 \n" ) sys.exit(1) if CARREXT == "on": extcarr = dtv.CARRIERS_EXTENDED elif CARREXT == "off": extcarr = dtv.CARRIERS_NORMAL else: sys.stderr.write( "EXT-CARRIERS IN CONFIG WRONG! Values: on or off \n") sys.exit(1) cp_length = fft_length + (fft_length * mul) / div ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + 'hackrf,buffers=128,buflen=32768') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(band_width, 0) self.dtv_dvbt2_pilotgenerator_cc_0 = dtv.dvbt2_pilotgenerator_cc( extcarr, ffts, pil, gint, DATASYM, pap, ver, preamb, dtv.MISO_TX1, dtv.EQUALIZATION_OFF, dtv.BANDWIDTH_8_0_MHZ, fft_length) self.dtv_dvbt2_p1insertion_cc_0 = dtv.dvbt2_p1insertion_cc( extcarr, ffts, gint, DATASYM, preamb, dtv.SHOWLEVELS_OFF, 3.3) self.dtv_dvbt2_modulator_bc_0 = dtv.dvbt2_modulator_bc( dtv.FECFRAME_NORMAL, const, dtv.ROTATION_OFF) self.dtv_dvbt2_interleaver_bb_0 = dtv.dvbt2_interleaver_bb( dtv.FECFRAME_NORMAL, codr, const) self.dtv_dvbt2_freqinterleaver_cc_0 = dtv.dvbt2_freqinterleaver_cc( extcarr, ffts, pil, gint, DATASYM, pap, ver, preamb) self.dtv_dvbt2_framemapper_cc_0 = dtv.dvbt2_framemapper_cc( dtv.FECFRAME_NORMAL, codr, const, dtv.ROTATION_OFF, FECBLKS, 3, extcarr, ffts, gint, l1m, pil, 2, DATASYM, pap, ver, preamb, dtv.INPUTMODE_NORMAL, dtv.RESERVED_OFF, dtv.L1_SCRAMBLED_OFF, dtv.INBAND_OFF) self.dtv_dvbt2_cellinterleaver_cc_0 = dtv.dvbt2_cellinterleaver_cc( dtv.FECFRAME_NORMAL, const, FECBLKS, 3) self.dtv_dvb_ldpc_bb_0 = dtv.dvb_ldpc_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr, dtv.MOD_OTHER) self.dtv_dvb_bch_bb_0 = dtv.dvb_bch_bb(dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr) self.dtv_dvb_bbscrambler_bb_0 = dtv.dvb_bbscrambler_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr) self.dtv_dvb_bbheader_bb_0 = dtv.dvb_bbheader_bb( dtv.STANDARD_DVBT2, dtv.FECFRAME_NORMAL, codr, dtv.RO_0_35, dtv.INPUTMODE_HIEFF, dtv.INBAND_OFF, 168, 4000000) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_length, cp_length, 0, '') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.2, )) if infile == "-": self.blocks_file_descriptor_source_0 = blocks.file_descriptor_source( gr.sizeof_char * 1, 0, True) else: self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, infile, True) ################################################## # Connections ################################################## if infile == "-": self.connect((self.blocks_file_descriptor_source_0, 0), (self.dtv_dvb_bbheader_bb_0, 0)) else: self.connect((self.blocks_file_source_0, 0), (self.dtv_dvb_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.dtv_dvbt2_p1insertion_cc_0, 0)) self.connect((self.dtv_dvb_bbheader_bb_0, 0), (self.dtv_dvb_bbscrambler_bb_0, 0)) self.connect((self.dtv_dvb_bbscrambler_bb_0, 0), (self.dtv_dvb_bch_bb_0, 0)) self.connect((self.dtv_dvb_bch_bb_0, 0), (self.dtv_dvb_ldpc_bb_0, 0)) self.connect((self.dtv_dvb_ldpc_bb_0, 0), (self.dtv_dvbt2_interleaver_bb_0, 0)) self.connect((self.dtv_dvbt2_cellinterleaver_cc_0, 0), (self.dtv_dvbt2_framemapper_cc_0, 0)) self.connect((self.dtv_dvbt2_framemapper_cc_0, 0), (self.dtv_dvbt2_freqinterleaver_cc_0, 0)) self.connect((self.dtv_dvbt2_freqinterleaver_cc_0, 0), (self.dtv_dvbt2_pilotgenerator_cc_0, 0)) self.connect((self.dtv_dvbt2_interleaver_bb_0, 0), (self.dtv_dvbt2_modulator_bc_0, 0)) self.connect((self.dtv_dvbt2_modulator_bc_0, 0), (self.dtv_dvbt2_cellinterleaver_cc_0, 0)) self.connect((self.dtv_dvbt2_p1insertion_cc_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.dtv_dvbt2_pilotgenerator_cc_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
def create_ofdm_blocks(self): self.carrier_allocator = digital.ofdm_carrier_allocator_cvc(self.fft_len, self.occupied_carriers, self.pilot_carriers, self.pilot_symbols, self.sync_words, self.len_tag_key) self.ifft = fft.fft_vcc(self.fft_len, False, (), True, 1) ofdm_len = self.fft_len + self.cp_len self.ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(self.fft_len, ofdm_len, 0, self.len_tag_key)
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: dvbt-hackrf.py port [output_file]\n"); sys.exit(1) channel_mhz = 6 mode = dtv.T2k code_rate = dtv.C1_2 constellation = dtv.MOD_QPSK guard_interval = dtv.GI_1_32 symbol_rate = channel_mhz * 8000000.0 / 7 center_freq = 441000000 rf_gain = 14 if_gain = 40 if mode == dtv.T2k: factor = 1 carriers = 2048 elif mode == dtv.T8k: factor = 4 carriers = 8192 if guard_interval == dtv.GI_1_32: gi = carriers / 32 elif guard_interval == dtv.GI_1_16: gi = carriers / 16 elif guard_interval == dtv.GI_1_8: gi = carriers / 8 elif guard_interval == dtv.GI_1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver((136 * factor), 12, 17) dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate) dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver((1512 * factor), constellation, dtv.NH, mode) dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver((1512 * factor), mode, 1) dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1) dvbt_reference_signals = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, dtv.GI_1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087 * 2.5, )) out = osmosdr.sink() out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_map) tb.connect(dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
def __init__(self, options, msgq_limit=2, pad_for_usrp=True): """ Hierarchical block for sending packets Packets to be sent are enqueued by calling send_pkt. The output is the complex modulated signal at baseband. Args: options: pass modulation options from higher layers (fft length, occupied tones, etc.) msgq_limit: maximum number of messages in message queue (int) pad_for_usrp: If true, packets are padded such that they end up a multiple of 128 samples """ gr.hier_block2.__init__(self, "ofdm_mod", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._pad_for_usrp = pad_for_usrp self._modulation = options.modulation self._fft_length = options.fft_length self._occupied_tones = options.occupied_tones self._cp_length = options.cp_length win = [] #[1 for i in range(self._fft_length)] # Use freq domain to get doubled-up known symbol for correlation in time domain zeros_on_left = int(math.ceil((self._fft_length - self._occupied_tones)/2.0)) ksfreq = known_symbols_4512_3[0:self._occupied_tones] for i in range(len(ksfreq)): if((zeros_on_left + i) & 1): ksfreq[i] = 0 # hard-coded known symbols preambles = (ksfreq,) padded_preambles = list() for pre in preambles: padded = self._fft_length*[0,] padded[zeros_on_left : zeros_on_left + self._occupied_tones] = pre padded_preambles.append(padded) symbol_length = options.fft_length + options.cp_length mods = {"bpsk": 2, "qpsk": 4, "8psk": 8, "qam8": 8, "qam16": 16, "qam64": 64, "qam256": 256} arity = mods[self._modulation] rot = 1 if self._modulation == "qpsk": rot = (0.707+0.707j) # FIXME: pass the constellation objects instead of just the points if(self._modulation.find("psk") >= 0): constel = psk.psk_constellation(arity) rotated_const = map(lambda pt: pt * rot, constel.points()) elif(self._modulation.find("qam") >= 0): constel = qam.qam_constellation(arity) rotated_const = map(lambda pt: pt * rot, constel.points()) #print rotated_const self._pkt_input = digital.ofdm_mapper_bcv(rotated_const, msgq_limit, options.occupied_tones, options.fft_length) self.preambles = digital.ofdm_insert_preamble(self._fft_length, padded_preambles) self.ifft = fft.fft_vcc(self._fft_length, False, win, True) self.cp_adder = digital.ofdm_cyclic_prefixer(self._fft_length, symbol_length) self.scale = blocks.multiply_const_cc(1.0 / math.sqrt(self._fft_length)) self.connect((self._pkt_input, 0), (self.preambles, 0)) self.connect((self._pkt_input, 1), (self.preambles, 1)) self.connect(self.preambles, self.ifft, self.cp_adder, self.scale, self)