def test_004_t(self): """ Provoking RuntimeError exceptions providing wrong user input (earlier invisible SIGFPE). """ fft_len = 6 # Occupied carriers with self.assertRaises(RuntimeError) as oc: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, (), ((), ), ((), ), (), self.tsb_key) # Pilot carriers with self.assertRaises(RuntimeError) as pc: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, ((), ), (), ((), ), (), self.tsb_key) # Pilot carrier symbols with self.assertRaises(RuntimeError) as ps: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, ((), ), ((), ), (), (), self.tsb_key) self.assertEqual( str(oc.exception), "Occupied carriers must be of type vector of vector i.e. ((),).") self.assertEqual( str(pc.exception), "Pilot carriers must be of type vector of vector i.e. ((),).") self.assertEqual( str(ps.exception), "Pilot symbols must be of type vector of vector i.e. ((),).")
def test_002_t (self): """ same, but using negative carrier indices """ fft_len = 6 tx_symbols = (1, 2, 3) pilot_symbols = ((1j,),) occupied_carriers = ((-1, 1, 2),) pilot_carriers = ((3,),) expected_result = (1j, 0, 1, 0, 2, 3) src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), self.tsb_key) sink = blocks.tsb_vector_sink_c(fft_len) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink ) self.tb.run () self.assertEqual(sink.data()[0], expected_result)
def test_003_connect (self): """ Connect carrier_allocator to ofdm_serializer, make sure output==input """ fft_len = 8 n_syms = 1 occupied_carriers = ((1, 2, 6, 7),) pilot_carriers = ((3,),(5,)) pilot_symbols = ((1j,),(-1j,)) #tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) tx_data = (1, 2, 3, 4) src = blocks.vector_source_c(tx_data, False, 1) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), # No sync word self.tsb_key, True # Output is shifted (default) ) serializer = digital.ofdm_serializer_vcc( alloc, "", # Len tag key 0, # Symbols skipped "", # Carrier offset key True # Input is shifted (default) ) sink = blocks.tsb_vector_sink_c(tsb_key=self.tsb_key) self.tb.connect(src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_data), self.tsb_key), alloc, serializer, sink) self.tb.run () self.assertEqual(sink.data()[0], tx_data)
def test_001_t2(self): """ pretty simple (same as before, but odd fft len) """ fft_len = 5 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 occupied_carriers = ((0, 1, 2), ) pilot_carriers = ((-2, ), ) pilot_symbols = ((1j, ), ) expected_result = [1j, 0, 1, 2, 3] # ^ DC carrier src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), self.tsb_key) sink = blocks.tsb_vector_sink_c(vlen=fft_len, tsb_key=self.tsb_key) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result)
def test_001_t(self): """ pretty simple (the carrier allocation here is not a practical OFDM configuration!) """ fft_len = 6 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 pilot_symbols = ((1j, ), ) occupied_carriers = ((0, 1, 2), ) pilot_carriers = ((3, ), ) sync_word = (list(range(fft_len)), ) expected_result = sync_word[0] + [1j, 0, 0, 1, 2, 3] # ^ DC carrier src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_word, self.tsb_key) sink = blocks.tsb_vector_sink_c(vlen=fft_len, tsb_key=self.tsb_key) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result)
def test_001_t2 (self): """ pretty simple (same as before, but odd fft len) """ fft_len = 5 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 occupied_carriers = ((0, 1, 2),) pilot_carriers = ((-2,),) pilot_symbols = ((1j,),) expected_result = (1j, 0, 1, 2, 3) # ^ DC carrier tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) src = blocks.vector_source_c(tx_symbols, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result)
def test_002_t (self): """ same, but using negative carrier indices """ fft_len = 6 tx_symbols = (1, 2, 3) pilot_symbols = ((1j,),) occupied_carriers = ((-1, 1, 2),) pilot_carriers = ((3,),) expected_result = (1j, 0, 1, 0, 2, 3) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) src = blocks.vector_source_c(tx_symbols, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result)
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): """ pretty simple (the carrier allocation is not a practical OFDM configuration!) """ fft_len = 6 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 pilot_symbols = ((1j,),) occupied_carriers = ((0, 1, 2),) pilot_carriers = ((3,),) sync_word = (range(fft_len),) expected_result = tuple(sync_word[0] + [1j, 0, 0, 1, 2, 3]) # ^ DC carrier tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) src = blocks.vector_source_c(tx_symbols, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_word, tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run () self.assertEqual(sink.data(), expected_result)
def test_003_connect(self): """ Connect carrier_allocator to ofdm_serializer, make sure output==input """ fft_len = 8 n_syms = 1 occupied_carriers = ((1, 2, 6, 7), ) pilot_carriers = ((3, ), (5, )) pilot_symbols = ((1j, ), (-1j, )) #tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) tx_data = [1, 2, 3, 4] src = blocks.vector_source_c(tx_data, False, 1) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), # No sync word self.tsb_key, True # Output is shifted (default) ) serializer = digital.ofdm_serializer_vcc( alloc, "", # Len tag key 0, # Symbols skipped "", # Carrier offset key True # Input is shifted (default) ) sink = blocks.tsb_vector_sink_c(tsb_key=self.tsb_key) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_data), self.tsb_key), alloc, serializer, sink) self.tb.run() self.assertEqual(sink.data()[0], tx_data)
def test_001_t(self): """ pretty simple (the carrier allocation is not a practical OFDM configuration!) """ fft_len = 6 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 pilot_symbols = ((1j, ), ) occupied_carriers = ((0, 1, 2), ) pilot_carriers = ((3, ), ) sync_word = (range(fft_len), ) expected_result = tuple(sync_word[0] + [1j, 0, 0, 1, 2, 3]) # ^ DC carrier tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) src = blocks.vector_source_c(tx_symbols, False, 1, (tag, )) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_word, tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
def test_003_connect(self): """ Connect carrier_allocator to ofdm_serializer, make sure output==input """ fft_len = 8 n_syms = 1 occupied_carriers = ((1, 2, 6, 7),) pilot_carriers = ((3,), (5,)) pilot_symbols = ((1j,), (-1j,)) # tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) tx_data = (1, 2, 3, 4) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_data)) src = blocks.vector_source_c(tx_data, False, 1, (tag,)) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), # No sync word tag_name, True, # Output is shifted (default) ) serializer = digital.ofdm_serializer_vcc( alloc, "", 0, "", True # Len tag key # Symbols skipped # Carrier offset key # Input is shifted (default) ) sink = blocks.vector_sink_c() self.tb.connect(src, alloc, serializer, sink) self.tb.run() self.assertEqual(sink.data(), tx_data)
def test_001_t (self): """ pretty simple (the carrier allocation here is not a practical OFDM configuration!) """ fft_len = 6 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 pilot_symbols = ((1j,),) occupied_carriers = ((0, 1, 2),) pilot_carriers = ((3,),) sync_word = (list(range(fft_len)),) expected_result = tuple(sync_word[0] + [1j, 0, 0, 1, 2, 3]) # ^ DC carrier src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_word, self.tsb_key) sink = blocks.tsb_vector_sink_c(vlen=fft_len, tsb_key=self.tsb_key) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink ) self.tb.run() self.assertEqual(sink.data()[0], expected_result)
def test_001_t2(self): """ pretty simple (same as before, but odd fft len) """ fft_len = 5 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 occupied_carriers = ((0, 1, 2), ) pilot_carriers = ((-2, ), ) pilot_symbols = ((1j, ), ) expected_result = (1j, 0, 1, 2, 3) # ^ DC carrier tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) src = blocks.vector_source_c(tx_symbols, False, 1, (tag, )) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run() self.assertEqual(sink.data(), expected_result)
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, fft_len, cp_len, occupied_carriers, pilot_carriers, pilot_symbols, packet_len_tag, verbose=False): gr.hier_block2.__init__( self, "ofdm_symbols_to_frame_cvc", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, fft_len * gr.sizeof_gr_complex)) self.fft_len = fft_len self.cp_len = cp_len self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.packet_len_tag = packet_len_tag self.allocator = digital.ofdm_carrier_allocator_cvc( fft_len=self.fft_len, occupied_carriers=self.occupied_carriers, pilot_carriers=self.pilot_carriers, pilot_symbols=self.pilot_symbols, sync_words=[ utils.ofdm_make_sync_word1(self.fft_len, self.occupied_carriers, self.pilot_carriers), utils.ofdm_make_sync_word2(self.fft_len, self.occupied_carriers, self.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.connect(self, self.allocator, self.ffter, self) if verbose == True: self.connect( self, blocks.file_sink(itemsize=gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_input.gr')) self.connect( self.allocator, blocks.file_sink( itemsize=self.fft_len * gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_allocator.gr')) self.connect( self.ffter, blocks.file_sink(itemsize=self.fft_len * gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_ffter.gr'))
def __init__(self, fft_len, cp_len, occupied_carriers, pilot_carriers, pilot_symbols, packet_len_tag, verbose=False): gr.hier_block2.__init__( self, "ofdm_symbols_to_frame_cvc", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, fft_len*gr.sizeof_gr_complex) ) self.fft_len = fft_len self.cp_len = cp_len self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols self.packet_len_tag = packet_len_tag self.allocator = digital.ofdm_carrier_allocator_cvc( fft_len=self.fft_len, occupied_carriers=self.occupied_carriers, pilot_carriers=self.pilot_carriers, pilot_symbols=self.pilot_symbols, sync_words=[ utils.ofdm_make_sync_word1(self.fft_len, self.occupied_carriers, self.pilot_carriers), utils.ofdm_make_sync_word2(self.fft_len, self.occupied_carriers, self.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.connect(self, self.allocator, self.ffter, self) if verbose==True: self.connect(self, blocks.file_sink( itemsize=gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_input.gr') ) self.connect(self.allocator, blocks.file_sink( itemsize=self.fft_len*gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_allocator.gr') ) self.connect(self.ffter, blocks.file_sink( itemsize=self.fft_len*gr.sizeof_gr_complex, filename='ofdm_symbols_to_frame_ffter.gr') )
def test_003_t (self): """ more advanced: - 6 symbols per carrier - 2 pilots per carrier - have enough data for nearly 3 OFDM symbols - send that twice - add some random tags - don't shift """ tx_symbols = list(range(1, 16)); # 15 symbols pilot_symbols = ((1j, 2j), (3j, 4j)) occupied_carriers = ((1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14),) pilot_carriers = ((2, 13), (3, 12)) expected_result = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0, 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0, 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0) fft_len = 16 testtag1 = gr.tag_t() testtag1.offset = 0 testtag1.key = pmt.string_to_symbol('tag1') testtag1.value = pmt.from_long(0) testtag2 = gr.tag_t() testtag2.offset = 7 # On the 2nd OFDM symbol testtag2.key = pmt.string_to_symbol('tag2') testtag2.value = pmt.from_long(0) testtag3 = gr.tag_t() testtag3.offset = len(tx_symbols)+1 # First OFDM symbol of packet 2 testtag3.key = pmt.string_to_symbol('tag3') testtag3.value = pmt.from_long(0) testtag4 = gr.tag_t() testtag4.offset = 2*len(tx_symbols)-1 # Last OFDM symbol of packet 2 testtag4.key = pmt.string_to_symbol('tag4') testtag4.value = pmt.from_long(0) src = blocks.vector_source_c(tx_symbols * 2, False, 1, (testtag1, testtag2, testtag3, testtag4)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), self.tsb_key, False) sink = blocks.tsb_vector_sink_c(fft_len) self.tb.connect(src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink) self.tb.run () self.assertEqual(sink.data()[0], expected_result) tags_found = {'tag1': False, 'tag2': False, 'tag3': False, 'tag4': False} correct_offsets = {'tag1': 0, 'tag2': 1, 'tag3': 3, 'tag4': 5} for tag in sink.tags(): key = pmt.symbol_to_string(tag.key) if key in list(tags_found.keys()): tags_found[key] = True self.assertEqual(correct_offsets[key], tag.offset) self.assertTrue(all(tags_found.values()))
def test_004_connect(self): """ Advanced test: - Allocator -> IFFT -> Frequency offset -> FFT -> Serializer - FFT does shift (moves DC to middle) - Make sure input == output - Frequency offset is -2 carriers """ fft_len = 8 n_syms = 1 carr_offset = -2 freq_offset = 1.0 / fft_len * carr_offset # Normalized frequency occupied_carriers = ((-2, -1, 1, 2),) pilot_carriers = ((-3,), (3,)) pilot_symbols = ((1j,), (-1j,)) tx_data = (1, 2, 3, 4) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_data)) offsettag = gr.tag_t() offsettag.offset = 0 offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") offsettag.value = pmt.from_long(carr_offset) src = blocks.vector_source_c(tx_data, False, 1, (tag, offsettag)) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name ) tx_ifft = fft.fft_vcc(fft_len, False, (1.0 / fft_len,) * fft_len, True) oscillator = analog.sig_source_c(1.0, analog.GR_COS_WAVE, freq_offset, 1.0 / fft_len) mixer = blocks.multiply_cc() rx_fft = fft.fft_vcc(fft_len, True, (), True) sink2 = blocks.vector_sink_c(fft_len) self.tb.connect(rx_fft, sink2) serializer = digital.ofdm_serializer_vcc(alloc, "", 0, "ofdm_sync_carr_offset", True) sink = blocks.vector_sink_c() self.tb.connect( src, alloc, tx_ifft, blocks.vector_to_stream(gr.sizeof_gr_complex, fft_len), (mixer, 0), blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), rx_fft, serializer, sink, ) self.tb.connect(oscillator, (mixer, 1)) self.tb.run() self.assertComplexTuplesAlmostEqual(sink.data()[-len(occupied_carriers[0]) :], tx_data, places=4)
def test_004_connect (self): """ Advanced test: - Allocator -> IFFT -> Frequency offset -> FFT -> Serializer - FFT does shift (moves DC to middle) - Make sure input == output - Frequency offset is -2 carriers """ fft_len = 8 n_syms = 1 carr_offset = -2 freq_offset = 1.0 / fft_len * carr_offset # Normalized frequency occupied_carriers = ((-2, -1, 1, 2),) pilot_carriers = ((-3,),(3,)) pilot_symbols = ((1j,),(-1j,)) tx_data = (1, 2, 3, 4) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_data)) offsettag = gr.tag_t() offsettag.offset = 0 offsettag.key = pmt.string_to_symbol("ofdm_sync_carr_offset") offsettag.value = pmt.from_long(carr_offset) src = blocks.vector_source_c(tx_data, False, 1, (tag, offsettag)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name) tx_ifft = fft.fft_vcc(fft_len, False, (1.0/fft_len,)*fft_len, True) oscillator = analog.sig_source_c(1.0, analog.GR_COS_WAVE, freq_offset, 1.0) mixer = blocks.multiply_cc() rx_fft = fft.fft_vcc(fft_len, True, (), True) sink2 = blocks.vector_sink_c(fft_len) self.tb.connect(rx_fft, sink2) serializer = digital.ofdm_serializer_vcc( alloc, "", 0, "ofdm_sync_carr_offset", True ) sink = blocks.vector_sink_c() self.tb.connect( src, alloc, tx_ifft, blocks.vector_to_stream(gr.sizeof_gr_complex, fft_len), (mixer, 0), blocks.stream_to_vector(gr.sizeof_gr_complex, fft_len), rx_fft, serializer, sink ) self.tb.connect(oscillator, (mixer, 1)) self.tb.run () self.assertComplexTuplesAlmostEqual(sink.data()[-len(occupied_carriers[0]):], tx_data, places=4)
def test_004_t (self): """ Provoking RuntimeError exceptions providing wrong user input (earlier invisible SIGFPE). """ fft_len = 6 # Occupied carriers with self.assertRaises(RuntimeError) as oc: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, (), ((),), ((),), (), self.tsb_key) # Pilot carriers with self.assertRaises(RuntimeError) as pc: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, ((),), (), ((),), (), self.tsb_key) # Pilot carrier symbols with self.assertRaises(RuntimeError) as ps: alloc = digital.ofdm_carrier_allocator_cvc(fft_len, ((),), ((),), (), (), self.tsb_key) self.assertEqual(str(oc.exception), "Occupied carriers must be of type vector of vector i.e. ((),).") self.assertEqual(str(pc.exception), "Pilot carriers must be of type vector of vector i.e. ((),).") self.assertEqual(str(ps.exception), "Pilot symbols must be of type vector of vector i.e. ((),).")
def test_002_t(self): """ once again, but this time add a sync word """ fft_len = 6 sync_word = (0, ) * fft_len tx_symbols = (1, 2, 3, 4, 5, 6) pilot_symbols = ((1j, ), ) occupied_carriers = ((-1, 1, 2), ) pilot_carriers = ((3, ), ) expected_result = sync_word + (1j, 0, 1, 0, 2, 3) + (1j, 0, 4, 0, 5, 6) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_symbols)) special_tag1 = gr.tag_t() special_tag1.offset = 0 special_tag1.key = pmt.string_to_symbol("spam") special_tag1.value = pmt.to_pmt(23) special_tag2 = gr.tag_t() special_tag2.offset = 4 special_tag2.key = pmt.string_to_symbol("eggs") special_tag2.value = pmt.to_pmt(42) src = blocks.vector_source_c(tx_symbols, False, 1, (tag, special_tag1, special_tag2)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_words=(sync_word, ), len_tag_key=tag_name) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, 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]) tags_expected = [ (0, 'len', 3), (0, 'spam', 23), (2, 'eggs', 42), ] self.assertEqual(tags, tags_expected)
def test_002_t (self): """ once again, but this time add a sync word """ fft_len = 6 sync_word = (0,) * fft_len tx_symbols = (1, 2, 3, 4, 5, 6) pilot_symbols = ((1j,),) occupied_carriers = ((-1, 1, 2),) pilot_carriers = ((3,),) expected_result = sync_word + (1j, 0, 1, 0, 2, 3) + (1j, 0, 4, 0, 5, 6) special_tag1 = gr.tag_t() special_tag1.offset = 0 special_tag1.key = pmt.string_to_symbol("spam") special_tag1.value = pmt.to_pmt(23) special_tag2 = gr.tag_t() special_tag2.offset = 4 special_tag2.key = pmt.string_to_symbol("eggs") special_tag2.value = pmt.to_pmt(42) src = blocks.vector_source_c( tx_symbols, False, 1, (special_tag1, special_tag2) ) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, sync_words=(sync_word,), len_tag_key=self.tsb_key ) sink = blocks.tsb_vector_sink_c(fft_len) self.tb.connect(src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, 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]) tags_expected = [ (0, 'spam', 23), (2, 'eggs', 42), ] self.assertEqual(tags, tags_expected)
def test_002_t(self): """ same, but using negative carrier indices """ fft_len = 6 tx_symbols = (1, 2, 3) pilot_symbols = ((1j, ), ) occupied_carriers = ((-1, 1, 2), ) pilot_carriers = ((3, ), ) expected_result = [1j, 0, 1, 0, 2, 3] src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), self.tsb_key) sink = blocks.tsb_vector_sink_c(fft_len) self.tb.connect( src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink) self.tb.run() self.assertEqual(sink.data()[0], expected_result)
def __init__(self, fft_size=64, 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=((1, 1, 1, -1,),)): gr.hier_block2.__init__( self, "PilotSymbols", gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]), gr.io_signature(1, 1, gr.sizeof_gr_complex*64), ) ################################################## # Parameters ################################################## self.fft_size = fft_size self.occupied_carriers = occupied_carriers self.pilot_carriers = pilot_carriers self.pilot_symbols = pilot_symbols ################################################## # Variables ################################################## self.word_sync2 = word_sync2 = [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.word_sync1 = word_sync1 = [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.paquete_tam = paquete_tam = 96 self.length_tag_key = length_tag_key = "paquete_tam" ################################################## # Blocks ################################################## self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(fft_size, occupied_carriers, pilot_carriers, pilot_symbols, (word_sync1,word_sync2), length_tag_key) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0) ################################################## # Connections ################################################## self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self, 0)) self.connect((self, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self, 1), (self.blocks_tagged_stream_mux_0, 1))
def test_003_connect(self): """ Connect carrier_allocator to ofdm_serializer, make sure output==input """ fft_len = 8 n_syms = 1 occupied_carriers = ((1, 2, 6, 7), ) pilot_carriers = ((3, ), (5, )) pilot_symbols = ((1j, ), (-1j, )) #tx_data = tuple([numpy.random.randint(0, 10) for x in range(4 * n_syms)]) tx_data = (1, 2, 3, 4) tag_name = "len" tag = gr.tag_t() tag.offset = 0 tag.key = pmt.string_to_symbol(tag_name) tag.value = pmt.from_long(len(tx_data)) src = blocks.vector_source_c(tx_data, False, 1, (tag, )) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), # No sync word tag_name, True # Output is shifted (default) ) serializer = digital.ofdm_serializer_vcc( alloc, "", # Len tag key 0, # Symbols skipped "", # Carrier offset key True # Input is shifted (default) ) sink = blocks.vector_sink_c() self.tb.connect(src, alloc, serializer, sink) self.tb.run() self.assertEqual(sink.data(), tx_data)
def test_001_t2 (self): """ pretty simple (same as before, but odd fft len) """ fft_len = 5 tx_symbols = (1, 2, 3) # ^ this gets mapped to the DC carrier because occupied_carriers[0][0] == 0 occupied_carriers = ((0, 1, 2),) pilot_carriers = ((-2,),) pilot_symbols = ((1j,),) expected_result = (1j, 0, 1, 2, 3) # ^ DC carrier src = blocks.vector_source_c(tx_symbols, False, 1) alloc = digital.ofdm_carrier_allocator_cvc( fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), self.tsb_key ) sink = blocks.tsb_vector_sink_c(vlen=fft_len, tsb_key=self.tsb_key) self.tb.connect(src, blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, len(tx_symbols), self.tsb_key), alloc, sink) self.tb.run () self.assertEqual(sink.data()[0], expected_result)
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, 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 __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 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, 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): grc_wxgui.top_block_gui.__init__(self, title="OFDM Tx") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # 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_name = length_tag_name = "packet_len" self.sync_word2 = sync_word2 = (0, 0, 0, 0, 0, 1, 1, -1.0, -1, 1.0, 1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 1, 1.0, 1, -1.0, -1, -1.0, -1, 1.0, -1, 1.0, -1, 1.0, 1, -1.0, 0, 1.0, 1, -1.0, 1, 1.0, -1, -1.0, 1, -1.0, -1, -1.0, 1, 1.0, 1, -1.0, 1, 1.0, -1, 1.0, -1, -1.0, -1, 1.0, 1, -1.0, 0, 0, 0, 0, 0, 0) self.sync_word1 = sync_word1 = (0, 0, 0, 0, 0, 0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, -1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, 1.0, 0, -1.0, 0, 1.0, 0, -1.0, 0, 0, 0, 0, 0, 0) self.samp_rate = samp_rate = 100000 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_name) self.fft_len = fft_len = 64 ################################################## # 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=False, num_inputs=1, trig_mode=gr.gr_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=0, y_per_div=10, y_divs=10, ref_level=0, 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, ) self.Add(self.wxgui_fftsink2_0.win) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), False, 1) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(header_formatter.formatter()) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len+fft_len/4, rolloff, length_tag_name) self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, length_tag_name) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_name) 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_vector_source_x_1 = blocks.vector_source_c(tuple(numpy.array(sync_word1) * numpy.sqrt(2)) + sync_word2, True, fft_len, tagged_streams.make_lengthtags((2,), (0,), length_tag_name)) self.blocks_vector_source_x_0 = blocks.vector_source_b(range(packet_len), True, 1, tagged_streams.make_lengthtags((packet_len,), (0,), length_tag_name)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_tagged_stream_mux_1 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*fft_len, length_tag_name) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_name) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), length_tag_name, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) ################################################## # Connections ################################################## self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.blocks_tagged_stream_mux_1, 1)) self.connect((self.blocks_tagged_stream_mux_1, 0), (self.fft_vxx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.digital_ofdm_carrier_allocator_cvc_0, 0)) self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_tagged_stream_mux_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, fD=10): gr.top_block.__init__(self, "Polar Coding with Coded Caching") ################################################## # Parameters ################################################## self.fD = fD ################################################## # Variables ################################################## self.snr_pld = snr_pld = 10 self.boost = boost = 15 self.snr = snr = 30 + 0 * (snr_pld + boost) 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.variance = variance = 1 / pow(10, snr / 10.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.small_packet_len = small_packet_len = 52 self.samp_rate = samp_rate = int(1e6) self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.id_user = id_user = 0 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 0, 1) self.Users = Users = 4 self.Nbfiles = Nbfiles = 20 self.NbStrgUsers = NbStrgUsers = 1 self.NbChuncks = NbChuncks = 200 self.N = N = 2048 ################################################## # Blocks ################################################## self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_gr_complex, 1, 'tcp://*:5565', 100, False, -1) self.zeromq_pub_msg_sink_0_0_0 = zeromq.pub_msg_sink( 'tcp://*:5575', 10) self.zeromq_pub_msg_sink_0_0 = zeromq.pub_msg_sink('tcp://*:5555', 10) self.projectCACHE_polarEnc_b_0_0 = projectCACHE.polarEnc_b( N, Nbfiles, NbChuncks, NbStrgUsers, id_user, small_packet_len, packet_length_tag_key) self.projectCACHE_map_header_payload_bc_0 = projectCACHE.map_header_payload_bc( 4, 2, 'packet_len') self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), packet_length_tag_key) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer( fft_len, fft_len + fft_len / 4, 0, packet_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), packet_length_tag_key) self.digital_chunks_to_symbols_xx_0_1 = digital.chunks_to_symbols_bc( (header_mod.points()), 1) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0) (self.blocks_tagged_stream_mux_0).set_max_output_buffer(8192) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((.05, )) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.zeromq_pub_msg_sink_0_0_0, 'in')) self.msg_connect((self.projectCACHE_polarEnc_b_0_0, 'BER_INFO'), (self.zeromq_pub_msg_sink_0_0, 'in')) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_1, 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_1, 0), (self.blocks_tagged_stream_mux_0, 0)) self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_1, 0)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0)) self.connect((self.projectCACHE_map_header_payload_bc_0, 0), (self.blocks_tagged_stream_mux_0, 1)) self.connect((self.projectCACHE_polarEnc_b_0_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.projectCACHE_polarEnc_b_0_0, 0), (self.projectCACHE_map_header_payload_bc_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, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_ofdm") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.occupied_carriers = occupied_carriers = ( range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27), ) self.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 = 100000 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 = 478 self.header_mod = header_mod = digital.constellation_bpsk() self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) self.fft_len = fft_len = 64 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('serial= 31DDAA6', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(3000000) self.uhd_usrp_sink_0.set_center_freq(1E9, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'FFT Plot', #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, length_tag_key) 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_tag_gate_0.set_single_key("") 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_vcc((0.05, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/csy/worktest/spectrum_sense/mydatafile/mydata_v2.log', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.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_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_tag_gate_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.qtgui_time_sink_x_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_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, 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 ################################################ crc = digital.crc32_bb(False, self.packet_length_tag_key) 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, crc, header_gen, header_mod, (header_payload_mux, 0) ) if debug_log: self.connect(header_gen, blocks.file_sink(1, 'tx-hdr.dat')) ### 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( crc, 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 = mofdm.ofdm_cyclic_prefixer( self.fft_len, self.fft_len+self.cp_len, rolloff, self.packet_length_tag_key ) self.connect(header_payload_mux, allocator, ffter, cyclic_prefixer, self) if debug_log: self.connect(allocator, blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'tx-post-allocator.dat')) self.connect(cyclic_prefixer, blocks.file_sink(gr.sizeof_gr_complex, 'tx-signal.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 __init__(self, input_port_num="55555", output_port_num="55556", rx_bw=1e6, rx_freq=2.2e9, rx_gain=0.8, serial_num="31C9237", tx_bw=1e6, tx_freq=2.2e9, tx_gain=0.8): gr.top_block.__init__(self, "tranceiver_ofdm_usrp_RS") ################################################## # Parameters ################################################## self.input_port_num = input_port_num self.output_port_num = output_port_num self.rx_bw = rx_bw self.rx_freq = rx_freq self.rx_gain = rx_gain self.serial_num = serial_num self.tx_bw = tx_bw self.tx_freq = tx_freq self.tx_gain = tx_gain ################################################## # Variables ################################################## self.packet_len = packet_len = 200 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.n = n = 255 self.length_tag_key = length_tag_key = "frame_len" self.k = k = packet_len + 4 self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.blocks_RS = blocks_RS = 1 self.t = t = int((n * blocks_RS - k) / 2) self.sync_word2 = sync_word2 = [ 0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), 0j, 0j, 0j, 0j, 0j ] self.sync_word1 = sync_word1 = [ 0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0. ] self.samp_rate = samp_rate = 10000 self.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.out_buf_size = out_buf_size = 0 self.header_formatter = header_formatter = digital.packet_header_ofdm( occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe( fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm( occupied_carriers, 1, length_tag_key, ) ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source( gr.sizeof_char, 1, "tcp://127.0.0.1:" + input_port_num, 100, False, -1) self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, "tcp://127.0.0.1:55556", 100, False, -1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_samp_rate(rx_bw) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='', channels=list(range(0, 1)), ), packet_length_tag_key, ) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_samp_rate(tx_bw) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 100, 1000) 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.dtv_dvbt_reed_solomon_enc_0 = dtv.dvbt_reed_solomon_enc( 2, 8, 0x11d, n, k, t, 0, blocks_RS) self.dtv_dvbt_reed_solomon_dec_0 = dtv.dvbt_reed_solomon_dec( 2, 8, 0x11d, n, k, t, 0, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb( hdr_format, packet_length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b( header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb( fft_len, fft_len // 4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc( fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc( payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc( header_equalizer.base(), fft_len // 4, length_tag_key, True, 1) self.digital_ofdm_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, True) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len // 4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_crc32_bb_0_0 = digital.crc32_bb(False, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb( payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( header_mod.base()) self.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_vector_to_stream_0_0 = blocks.vector_to_stream( gr.sizeof_char * 1, k) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_char * 1, n) self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux( gr.sizeof_gr_complex * 1, packet_length_tag_key, 0) self.blocks_tagged_stream_multiply_length_0_0 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, packet_length_tag_key, k / n) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, packet_length_tag_key, n / k) self.blocks_stream_to_vector_1 = blocks.stream_to_vector( gr.sizeof_char * 1, k) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_char * 1, n) self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, k, packet_length_tag_key) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, packet_len, packet_length_tag_key) self.blocks_repack_bits_bb_0_1 = 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_0 = blocks.repack_bits_bb( 8, 1, 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_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, fft_len + fft_len // 4) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc( -2.0 / fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'), (self.digital_header_payload_demux_0, 'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_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.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 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, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0), (self.blocks_tagged_stream_multiply_length_0_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.dtv_dvbt_reed_solomon_dec_0, 0)) self.connect((self.blocks_stream_to_vector_1, 0), (self.dtv_dvbt_reed_solomon_enc_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_repack_bits_bb_0_1, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.digital_protocol_formatter_bb_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0_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.blocks_vector_to_stream_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_stream_to_tagged_stream_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_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_crc32_bb_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_stream_to_vector_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0, 0)) self.connect((self.digital_header_payload_demux_0, 1), (self.fft_vxx_1, 0)) self.connect((self.digital_ofdm_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_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_dec_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.dtv_dvbt_reed_solomon_enc_0, 0), (self.blocks_vector_to_stream_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.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 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.zeromq_sub_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
def __init__(self): gr.top_block.__init__(self, "OFDM Tx") Qt.QWidget.__init__(self) self.setWindowTitle("OFDM Tx") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "tx_ofdm_updated") 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_bpsk() 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 = length_tag_key = "packet_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.tx_probe = tx_probe = 0 self.sync_word2_0 = sync_word2_0 = [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_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_0 = sync_word1_0 = [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.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 = 50000 self.rx_probe = rx_probe = 0 self.rolloff = rolloff = 0 self.pilot_symbols_0 = pilot_symbols_0 = ((1, 1, 1, -1,),) self.pilot_carriers_0 = pilot_carriers_0 = ((-21, -7, 7, 21,),) self.payload_mod_0 = payload_mod_0 = digital.constellation_qpsk() self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.packet_len_0 = packet_len_0 = 96 self.packet_len = packet_len = 96 self.output_signal = output_signal = 0 self.og_signal_probe = og_signal_probe = 0 self.occupied_carriers_0 = occupied_carriers_0 = (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_0 = length_tag_key_0 = "frame_len" self.input_signal = input_signal = 0 self.header_mod_0 = header_mod_0 = digital.constellation_bpsk() self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.hdr_format = hdr_format = digital.header_format_ofdm(occupied_carriers, 1, length_tag_key,) self.fft_len_0 = fft_len_0 = 64 self.decoded_probe = decoded_probe = 0 ################################################## # Blocks ################################################## self.blocks_probe_signal_x_4 = blocks.probe_signal_c() self.blocks_probe_signal_x_3 = blocks.probe_signal_c() self.blocks_probe_signal_x_2 = blocks.probe_signal_b() self.blocks_probe_signal_x_0_1 = blocks.probe_signal_b() self.blocks_probe_signal_x_0_0_0 = blocks.probe_signal_c() self.blocks_probe_signal_x_0_0 = blocks.probe_signal_c() def _tx_probe_probe(): global transmitted_data while True: val = self.blocks_probe_signal_x_0_0.level() transmitted_data = val try: self.set_tx_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _tx_probe_thread = threading.Thread(target=_tx_probe_probe) _tx_probe_thread.daemon = True _tx_probe_thread.start() def _rx_probe_probe(): global received_data while True: val = self.blocks_probe_signal_x_3.level() received_data = val try: self.set_rx_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _rx_probe_thread = threading.Thread(target=_rx_probe_probe) _rx_probe_thread.daemon = True _rx_probe_thread.start() self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Scope Plot', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = ['Scope Plot', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ['blue', 'red', 'green', 'black', 'cyan', 'magenta', 'yellow', 'dark red', 'dark green', 'dark blue'] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'FFT Plot', #name 1 ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) def _output_signal_probe(): global output_data while True: val = self.blocks_probe_signal_x_0_1.level() output_data = val try: self.set_output_signal(val) except AttributeError: pass # time.sleep(1.0 / (10)) time.sleep(0.0911) _output_signal_thread = threading.Thread(target=_output_signal_probe) _output_signal_thread.daemon = True _output_signal_thread.start() def _og_signal_probe_probe(): global encoded_data while True: val = self.blocks_probe_signal_x_0_0_0.level() encoded_data = val try: self.set_og_signal_probe(val) except AttributeError: pass time.sleep(1.0 / (10)) _og_signal_probe_thread = threading.Thread(target=_og_signal_probe_probe) _og_signal_probe_thread.daemon = True _og_signal_probe_thread.start() def _input_signal_probe(): global input_data while True: val = self.blocks_probe_signal_x_2.level() input_data = val try: self.set_input_signal(val) except AttributeError: pass time.sleep(1.0 / (10)) _input_signal_thread = threading.Thread(target=_input_signal_probe) _input_signal_thread.daemon = True _input_signal_thread.start() self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0_0 = fft.fft_vcc(fft_len, True, (), True, 1) self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1) self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key) self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(header_formatter.base()) self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len//4, False, 0.9) self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, packet_length_tag_key, 1, '', True) self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(fft_len, occupied_carriers, length_tag_key, '', 0, '', True) self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(payload_equalizer.base(), fft_len//4, length_tag_key, True, 0) self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), fft_len//4, length_tag_key, True, 1) self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len + fft_len//4, rolloff, 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), length_tag_key, True) self.digital_header_payload_demux_0 = digital.header_payload_demux( 3, fft_len, fft_len//4, length_tag_key, "", True, gr.sizeof_gr_complex, "rx_time", samp_rate, (), 0) self.digital_crc32_bb_0_0 = digital.crc32_bb(True, packet_length_tag_key, True) self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True) self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(payload_mod.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base()) self.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) def _decoded_probe_probe(): global decoded_signal while True: val = self.blocks_probe_signal_x_4.level() decoded_signal = val try: self.set_decoded_probe(val) except AttributeError: pass # time.sleep(1.0 / (10)) time.sleep(0.0911) _decoded_probe_thread = threading.Thread(target=_decoded_probe_probe) _decoded_probe_thread.daemon = True _decoded_probe_thread.start() self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0.15, frequency_offset=0 * 1.0/fft_len, epsilon=1.0, taps=[1.0 + 1.0j], noise_seed=0, block_tags=True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) 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_tag_gate_0.set_single_key("") self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char*1, 'Rx Bytes', "") self.blocks_tag_debug_1.set_display(True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, packet_len, length_tag_key) self.blocks_repack_bits_bb_0_1 = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_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_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05) 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(list(map(int, numpy.random.randint(0, 255, 1000))), True) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(-2.0/fft_len) ################################################## # Connections ################################################## self.msg_connect((self.digital_packet_headerparser_b_0, u'header_data'), (self.digital_header_payload_demux_0, u'header_data')) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_probe_signal_x_2, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_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_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_repack_bits_bb_0_1, 0), (self.blocks_probe_signal_x_0_1, 0)) self.connect((self.blocks_repack_bits_bb_0_1, 0), (self.digital_crc32_bb_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.blocks_throttle_0, 0)) self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_probe_signal_x_0_0_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, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_probe_signal_x_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_probe_signal_x_3, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.blocks_throttle_0_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_1, 0)) 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_crc32_bb_0_0, 0), (self.blocks_tag_debug_1, 0)) self.connect((self.digital_header_payload_demux_0, 0), (self.fft_vxx_0_0, 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)) 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.blocks_probe_signal_x_4, 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_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)) self.connect((self.fft_vxx_0_0, 0), (self.digital_ofdm_chanest_vcvc_0, 0)) self.connect((self.fft_vxx_1, 0), (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
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): gr.top_block.__init__(self, "Robot") Qt.QWidget.__init__(self) self.setWindowTitle("Robot") 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", "robot") 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_sink_0 = uhd.usrp_sink( ",".join(("serial=30CEEB2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(2.492e9, 0) self.uhd_usrp_sink_0.set_gain(200, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) 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.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1) self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb( header_formatter.formatter(), packet_length_tag_key) 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_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_crc32_bb_0_0 = digital.crc32_bb(False, packet_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, "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_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_message_strobe_0 = blocks.message_strobe( pmt.cons(pmt.make_dict(), pmt.make_u8vector(4, 1)), 100) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_crc32_bb_0_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_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, 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_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0_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, 0), (self.digital_ofdm_cyclic_prefixer_0, 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): 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 test_003_t(self): """ more advanced: - 6 symbols per carrier - 2 pilots per carrier - have enough data for nearly 3 OFDM symbols - send that twice - add some random tags - don't shift """ tx_symbols = range(1, 16) # 15 symbols pilot_symbols = ((1j, 2j), (3j, 4j)) occupied_carriers = ( (1, 3, 4, 11, 12, 14), (1, 2, 4, 11, 13, 14), ) pilot_carriers = ((2, 13), (3, 12)) expected_result = (0, 1, 1j, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 2j, 6, 0, 0, 7, 8, 3j, 9, 0, 0, 0, 0, 0, 0, 10, 4j, 11, 12, 0, 0, 13, 1j, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 2j, 0, 0) fft_len = 16 tag_name = "len" tag1 = gr.tag_t() tag1.offset = 0 tag1.key = pmt.string_to_symbol(tag_name) tag1.value = pmt.from_long(len(tx_symbols)) tag2 = gr.tag_t() tag2.offset = len(tx_symbols) tag2.key = pmt.string_to_symbol(tag_name) tag2.value = pmt.from_long(len(tx_symbols)) testtag1 = gr.tag_t() testtag1.offset = 0 testtag1.key = pmt.string_to_symbol('tag1') testtag1.value = pmt.from_long(0) testtag2 = gr.tag_t() testtag2.offset = 7 # On the 2nd OFDM symbol testtag2.key = pmt.string_to_symbol('tag2') testtag2.value = pmt.from_long(0) testtag3 = gr.tag_t() testtag3.offset = len(tx_symbols) + 1 # First OFDM symbol of packet 2 testtag3.key = pmt.string_to_symbol('tag3') testtag3.value = pmt.from_long(0) testtag4 = gr.tag_t() testtag4.offset = 2 * len( tx_symbols) - 1 # Last OFDM symbol of packet 2 testtag4.key = pmt.string_to_symbol('tag4') testtag4.value = pmt.from_long(0) src = blocks.vector_source_c( tx_symbols * 2, False, 1, (tag1, tag2, testtag1, testtag2, testtag3, testtag4)) alloc = digital.ofdm_carrier_allocator_cvc(fft_len, occupied_carriers, pilot_carriers, pilot_symbols, (), tag_name, False) sink = blocks.vector_sink_c(fft_len) self.tb.connect(src, alloc, sink) self.tb.run() self.assertEqual(sink.data(), expected_result * 2) tags_found = { 'tag1': False, 'tag2': False, 'tag3': False, 'tag4': False } correct_offsets = {'tag1': 0, 'tag2': 1, 'tag3': 3, 'tag4': 5} for tag in sink.tags(): key = pmt.symbol_to_string(tag.key) if key in tags_found.keys(): tags_found[key] = True self.assertEqual(correct_offsets[key], tag.offset) if key == tag_name: self.assertTrue(tag.offset == 0 or tag.offset == 3) self.assertTrue(pmt.to_long(tag.value) == 3) self.assertTrue(all(tags_found.values()))
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, 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, bandwidth=10e6, chan_est=ieee802_11.LS, encoding=ieee802_11.BPSK_1_2, frequency=5.89e9, sensitivity=0.56): gr.hier_block2.__init__( self, "WiFi PHY Hier", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("mac_in") self.message_port_register_hier_out("carrier") self.message_port_register_hier_out("mac_out") ################################################## # Parameters ################################################## self.bandwidth = bandwidth self.chan_est = chan_est self.encoding = encoding self.frequency = frequency self.sensitivity = sensitivity ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.max_symbols = max_symbols = 5 + 1 + ((16 + 1540 * 8 + 6) * 2) / 24 self.header_formatter = header_formatter = ieee802_11.signal_field() ################################################## # Blocks ################################################## self.sync_short = ieee802_11.sync_short(sensitivity, 2, False, False) self.sync_long = ieee802_11.sync_long(sync_length, False, False) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_cc(window_size) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_ff(window_size + 16) self.ieee802_11_mapper_0 = ieee802_11.mapper(encoding, False) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer(chan_est, frequency, bandwidth, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(False, False) 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(397056) self.fft_vxx_0_1 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) 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(397056) 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(397056) 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(397056) 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(397056) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self, 'mac_out')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self, 'carrier')) self.msg_connect((self, 'mac_in'), (self.ieee802_11_mapper_0, 'in')) 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_0, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.sync_long, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.sync_short, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.sync_short, 2)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0_1, 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, 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.fft_vxx_0_1, 0), (self.ieee802_11_frame_equalizer_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_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_mapper_0, 0), (self.digital_packet_headergenerator_bb_0, 0)) self.connect((self.ieee802_11_mapper_0, 0), (self.ieee802_11_chunks_to_symbols_xx_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.sync_short, 1)) self.connect((self, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self, 0), (self.blocks_delay_0_0, 0)) self.connect((self, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.sync_long, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.sync_short, 0), (self.blocks_delay_0, 0)) self.connect((self.sync_short, 0), (self.sync_long, 0))