def test_preserve_tag_head_pos(self):
     """ Test the 'preserve head position' function.
     This will add a 'special' tag to item 0 on stream 1.
     It should be on item 0 of the output stream. """
     packet_len_0 = 5
     data0 = range(packet_len_0)
     packet_len_1 = 3
     data1 = range(packet_len_1)
     mux = blocks.tagged_stream_mux(
             gr.sizeof_float,
             self.tsb_key,
             1 # Mark port 1 as carrying special tags on the head position
     )
     sink = blocks.tsb_vector_sink_f(tsb_key=self.tsb_key)
     self.tb.connect(
         blocks.vector_source_f(data0),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_0, self.tsb_key),
         (mux, 0)
     )
     self.tb.connect(
         blocks.vector_source_f(range(packet_len_1), tags=(make_tag('spam', 'eggs', 0),)),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_1, self.tsb_key),
         (mux, 1)
     )
     self.tb.connect(mux, sink)
     self.tb.run()
     self.assertEqual(len(sink.data()), 1)
     self.assertEqual(sink.data()[0], tuple(data0 + data1))
     self.assertEqual(len(sink.tags()), 1)
     tag = gr.tag_to_python(sink.tags()[0])
     tag = (tag.offset, tag.key, tag.value)
     tag_expected = (0, 'spam', 'eggs')
     self.assertEqual(tag, tag_expected)
Exemplo n.º 2
0
    def __init__(self, payload_packet_len=96, sync_packet_len=96):
        gr.hier_block2.__init__(self,
            "Generic transmission path",
            gr.io_signaturev(2, 2, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            )

        ##################################################
        # Parameters
        ##################################################
        self.payload_packet_len = payload_packet_len
        self.sync_packet_len = sync_packet_len

        ##################################################
        # Variables
        ##################################################
        self.length_tag_name = length_tag_name = "packet_len"

        ##################################################
        # Blocks
        ##################################################
        self.dctk_stream_to_tagged_stream_cc_1 = dctk.stream_to_tagged_stream_cc(payload_packet_len, tagged_streams.make_lengthtags((payload_packet_len,), (0,), length_tag_name))
        self.dctk_stream_to_tagged_stream_cc_0 = dctk.stream_to_tagged_stream_cc(sync_packet_len, tagged_streams.make_lengthtags((sync_packet_len,), (0,), length_tag_name))
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_name)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self, 0))
        self.connect((self, 0), (self.dctk_stream_to_tagged_stream_cc_0, 0))
        self.connect((self.dctk_stream_to_tagged_stream_cc_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self, 1), (self.dctk_stream_to_tagged_stream_cc_1, 0))
        self.connect((self.dctk_stream_to_tagged_stream_cc_1, 0), (self.blocks_tagged_stream_mux_0, 1))
Exemplo n.º 3
0
    def setUp(self):
        self.tb = gr.top_block()
        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32e3
        self.preamble = preamble = get_random_bits(64 * 3)
        self.npreamble = len(self.preamble)
        # self.modulation = modulation = "QPSK"
        self.nbits = 16 * 3
        self.bits = get_random_bits(self.nbits)
        self.tag_preamble = gr.tag_t()
        self.tag_preamble.key = pmt.intern("pkt")
        self.tag_preamble.value = pmt.from_long(self.npreamble)
        self.tag_preamble.offset = 0
        self.tag_body = gr.tag_t()
        self.tag_body.key = pmt.intern("pkt")
        self.tag_body.value = pmt.from_long(self.nbits)

        ##################################################
        # Blocks
        ##################################################
        # self.modulator = modulator_classic(modulation)
        # self.demodulator = demodulator_neural(seed=0, hidden_layers=(64, ), bits_per_symbol=2, preamble=preamble)
        self.vector_source_preamble = blocks.vector_source_b(
            preamble, True, 1, [self.tag_preamble])
        self.vector_source_body = blocks.vector_source_b(
            self.bits, True, 1, [self.tag_body])
        self.tags_mux = blocks.tagged_stream_mux(gr.sizeof_char * 1, "pkt")
        self.strm_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt")
        self.pdu_to_strm = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt")
        self.vector_sink = blocks.vector_sink_b()
Exemplo n.º 4
0
 def test_preserve_tag_head_pos(self):
     """ Test the 'preserve head position' function.
     This will add a 'special' tag to item 0 on stream 1.
     It should be on item 0 of the output stream. """
     packet_len_0 = 5
     data0 = list(range(packet_len_0))
     packet_len_1 = 3
     data1 = list(range(packet_len_1))
     mux = blocks.tagged_stream_mux(
         gr.sizeof_float,
         self.tsb_key,
         1  # Mark port 1 as carrying special tags on the head position
     )
     sink = blocks.tsb_vector_sink_f(tsb_key=self.tsb_key)
     self.tb.connect(
         blocks.vector_source_f(data0),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_0,
                                        self.tsb_key), (mux, 0))
     self.tb.connect(
         blocks.vector_source_f(list(range(packet_len_1)),
                                tags=(make_tag('spam', 'eggs', 0), )),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_1,
                                        self.tsb_key), (mux, 1))
     self.tb.connect(mux, sink)
     self.tb.run()
     self.assertEqual(len(sink.data()), 1)
     self.assertEqual(sink.data()[0], tuple(data0 + data1))
     self.assertEqual(len(sink.tags()), 1)
     tag = gr.tag_to_python(sink.tags()[0])
     tag = (tag.offset, tag.key, tag.value)
     tag_expected = (0, 'spam', 'eggs')
     self.assertEqual(tag, tag_expected)
 def test_preserve_tag_head_pos(self):
     """ Test the 'preserve head position' function.
     This will add a 'special' tag to item 0 on stream 1.
     It should be on item 0 of the output stream. """
     special_tag = gr.tag_t()
     special_tag.key = pmt.string_to_symbol('spam')
     special_tag.offset = 0
     special_tag.value = pmt.to_pmt('eggs')
     len_tag_key = "length"
     packet_len_1 = 5
     packet_len_2 = 3
     mux = blocks.tagged_stream_mux(gr.sizeof_float, len_tag_key, 1)
     sink = blocks.vector_sink_f()
     self.tb.connect(
         blocks.vector_source_f(range(packet_len_1)),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_1, len_tag_key),
         (mux, 0)
     )
     self.tb.connect(
         blocks.vector_source_f(range(packet_len_2), False, 1, (special_tag,)),
         blocks.stream_to_tagged_stream(gr.sizeof_float, 1, packet_len_2, len_tag_key),
         (mux, 1)
     )
     self.tb.connect(mux, sink)
     self.tb.run()
     self.assertEqual(sink.data(), tuple(range(packet_len_1) + range(packet_len_2)))
     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, 'length', packet_len_1 + packet_len_2),
             (0, 'spam', 'eggs'),
     ]
     self.assertEqual(tags, tags_expected)
Exemplo n.º 6
0
 def test_1(self):
     packets0 = ((0, 1, 2), (5, 6), (10, ), (
         14,
         15,
         16,
     ))
     packets1 = ((3, 4), (7, 8, 9), (11, 12, 13), (17, ))
     expected = ((0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13),
                 (14, 15, 16, 17))
     data0, tags0 = self.setup_data_tags(packets0)
     data1, tags1 = self.setup_data_tags(packets1)
     tags0.append(make_tag('spam', 42, 4))
     tags1.append(make_tag('eggs', 23, 3))
     src0 = blocks.vector_source_b(data0, tags=tags0)
     src1 = blocks.vector_source_b(data1, tags=tags1)
     tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char,
                                                  self.tsb_key)
     snk = blocks.tsb_vector_sink_b(tsb_key=self.tsb_key)
     self.tb.connect(src0, (tagged_stream_mux, 0))
     self.tb.connect(src1, (tagged_stream_mux, 1))
     self.tb.connect(tagged_stream_mux, snk)
     self.tb.run()
     # Check
     self.assertEqual(expected, snk.data())
     tags = [gr.tag_to_python(x) for x in snk.tags()]
     tags = sorted([(x.offset, x.key, x.value) for x in tags])
     tags_expected = [
         (6, 'spam', 42),
         (8, 'eggs', 23),
     ]
     self.assertEqual(tags, tags_expected)
 def test_1(self):
     packets0 = (
         (0, 1, 2),  (5, 6),     (10,),         (14, 15, 16,)
     )
     packets1 = (
         (3, 4),     (7, 8, 9),  (11, 12, 13),  (17,)
     )
     expected = ((0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13), (14, 15, 16, 17))
     data0, tags0 = self.setup_data_tags(packets0)
     data1, tags1 = self.setup_data_tags(packets1)
     tags0.append(make_tag('spam', 42, 4))
     tags1.append(make_tag('eggs', 23, 3))
     src0 = blocks.vector_source_b(data0, tags=tags0)
     src1 = blocks.vector_source_b(data1, tags=tags1)
     tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, self.tsb_key)
     snk = blocks.tsb_vector_sink_b(tsb_key=self.tsb_key)
     self.tb.connect(src0, (tagged_stream_mux, 0))
     self.tb.connect(src1, (tagged_stream_mux, 1))
     self.tb.connect(tagged_stream_mux, snk)
     self.tb.run()
     # Check
     self.assertEqual(expected, snk.data())
     tags = [gr.tag_to_python(x) for x in snk.tags()]
     tags = sorted([(x.offset, x.key, x.value) for x in tags])
     tags_expected = [
             (6, 'spam', 42),
             (8, 'eggs', 23),
     ]
     self.assertEqual(tags, tags_expected)
Exemplo n.º 8
0
    def test_1(self):
        datas = (
            0, 1, 2,  5, 6,     10,          14, 15, 16,
            3, 4,     7, 8, 9,  11, 12, 13,  17
        )
        expected = tuple(range(18))

        tagname = "packet_length"
        len_tags_0 = (
            make_len_tag(0, tagname, 3),
            make_len_tag(3, tagname, 2),
            make_len_tag(5, tagname, 1),
            make_len_tag(6, tagname, 3)
        )
        len_tags_1 = (
            make_len_tag(0, tagname, 2),
            make_len_tag(2, tagname, 3),
            make_len_tag(5, tagname, 3),
            make_len_tag(8, tagname, 1)
        )
        test_tag_0 = gr.tag_t()
        test_tag_0.key = pmt.string_to_symbol('spam')
        test_tag_0.offset = 4 # On the second '1'
        test_tag_0.value = pmt.to_pmt(42)
        test_tag_1 = gr.tag_t()
        test_tag_1.key = pmt.string_to_symbol('eggs')
        test_tag_1.offset = 3 # On the first '3' of the 2nd stream
        test_tag_1.value = pmt.to_pmt(23)

        src0 = blocks.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,))
        src1 = blocks.vector_source_b(datas[9:],  False, 1, len_tags_1 + (test_tag_1,))
        tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, tagname)
        snk = blocks.vector_sink_b()
        self.tb.connect(src0, (tagged_stream_mux, 0))
        self.tb.connect(src1, (tagged_stream_mux, 1))
        self.tb.connect(tagged_stream_mux, snk)
        self.tb.run()

        self.assertEqual(expected, snk.data())

        tags = [gr.tag_to_python(x) for x in snk.tags()]
        tags = sorted([(x.offset, x.key, x.value) for x in tags])
        tags_expected = [
                (0, 'packet_length', 5),
                (5, 'packet_length', 5),
                (6, 'spam', 42),
                (8, 'eggs', 23),
                (10, 'packet_length', 4),
                (14, 'packet_length', 4)
        ]
        self.assertEqual(tags, tags_expected)
    def test_1(self):
        datas = (
            0, 1, 2,  5, 6,     10,          14, 15, 16,
            3, 4,     7, 8, 9,  11, 12, 13,  17
        )
        expected = tuple(range(18))

        tagname = "packet_length"
        len_tags_0 = (
            make_len_tag(0, tagname, 3),
            make_len_tag(3, tagname, 2),
            make_len_tag(5, tagname, 1),
            make_len_tag(6, tagname, 3)
        )
        len_tags_1 = (
            make_len_tag(0, tagname, 2),
            make_len_tag(2, tagname, 3),
            make_len_tag(5, tagname, 3),
            make_len_tag(8, tagname, 1)
        )
        test_tag_0 = gr.tag_t()
        test_tag_0.key = pmt.string_to_symbol('spam')
        test_tag_0.offset = 4 # On the second '1'
        test_tag_0.value = pmt.to_pmt(42)
        test_tag_1 = gr.tag_t()
        test_tag_1.key = pmt.string_to_symbol('eggs')
        test_tag_1.offset = 3 # On the first '3' of the 2nd stream
        test_tag_1.value = pmt.to_pmt(23)

        src0 = blocks.vector_source_b(datas[0:9], False, 1, len_tags_0 + (test_tag_0,))
        src1 = blocks.vector_source_b(datas[9:],  False, 1, len_tags_1 + (test_tag_1,))
        tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_char, tagname)
        snk = blocks.vector_sink_b()
        self.tb.connect(src0, (tagged_stream_mux, 0))
        self.tb.connect(src1, (tagged_stream_mux, 1))
        self.tb.connect(tagged_stream_mux, snk)
        self.tb.run()

        self.assertEqual(expected, snk.data())

        tags = [gr.tag_to_python(x) for x in snk.tags()]
        tags = sorted([(x.offset, x.key, x.value) for x in tags])
        tags_expected = [
                (0, 'packet_length', 5),
                (5, 'packet_length', 5),
                (6, 'spam', 42),
                (8, 'eggs', 23),
                (10, 'packet_length', 4),
                (14, 'packet_length', 4)
        ]
        self.assertEqual(tags, tags_expected)
Exemplo n.º 10
0
    def __init__(self, frameTag="packet_len", numRevs=20):
        gr.hier_block2.__init__(
            self,
            "AX.25 Packet Formatter",
            gr.io_signature(0, 0, 0),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_in("in")
        self.message_port_register_hier_out("out")

        ##################################################
        # Parameters
        ##################################################
        self.frameTag = frameTag
        self.numRevs = numRevs

        ##################################################
        # Blocks
        ##################################################
        self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb(frameTag)
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            tuple([0, 1, 1, 1, 1, 1, 1, 0] * numRevs), True, 1, [])
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, frameTag)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, frameTag, 0)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, numRevs * 8, frameTag)
        self.amateur_Tagged_Nrzi_Encoder_0 = amateur.Tagged_Nrzi_Encoder(
            frameTag, 1)
        self.amateur_AX25_Packet_Encoder_0 = amateur.AX25_Packet_Encoder()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.amateur_AX25_Packet_Encoder_0, 'pkt'),
                         (self.digital_hdlc_framer_pb_0, 'in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self, 'out'))
        self.msg_connect((self, 'in'),
                         (self.amateur_AX25_Packet_Encoder_0, 'data'))
        self.connect((self.amateur_Tagged_Nrzi_Encoder_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.amateur_Tagged_Nrzi_Encoder_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_hdlc_framer_pb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
 def test_001_t (self):
     self.header_formatter = header_formatter = ieee802_15_4a.packet_header_uwb(16, 16, 5, 31, 8)
     
     self.blocks_vector_source = blocks.vector_source_b(range(96), False, 1, tagged_streams.make_lengthtags((96,), (0,), "packet_len"))        
     self.blocks_tagged_stream_mux = blocks.tagged_stream_mux(1, "packet_len")        
     self.digital_packet_headergenerator_uwb = digital.packet_headergenerator_bb(header_formatter.formatter())
     self.sink = blocks.file_sink (1, "output_uwb.txt")
     
     self.tb.connect((self.blocks_vector_source, 0), (self.digital_packet_headergenerator_uwb, 0))
     self.tb.connect((self.blocks_vector_source, 0), (self.blocks_tagged_stream_mux, 1))
     self.tb.connect((self.digital_packet_headergenerator_uwb, 0), (self.blocks_tagged_stream_mux, 0))
     self.tb.connect((self.blocks_tagged_stream_mux, 0), (self.sink, 0))
     
     self.tb.run ()
Exemplo n.º 12
0
    def __init__(self, len_tag_key, fft_len, cp_len, occupied_carriers, pilot_symbols, pilot_carriers, sync_words):
        gr.hier_block2.__init__(self,
            "adaptive_ofdm_tx_bc",
            gr.io_signature(1, 1, gr.sizeof_char),
            gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self.len_tag_key = len_tag_key
        self.fft_len = fft_len
        self.cp_len = cp_len
        self.occupied_carriers = occupied_carriers
        self.pilot_carriers = pilot_carriers
        self.pilot_symbols = pilot_symbols
        self.sync_words = sync_words


        self.select_adaptive_mod()
        self.create_header_blocks()
        self.create_payload_blocks()
        self.tagged_stream_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex, self.len_tag_key, 0)
        self.create_ofdm_blocks()
        self.multiply = blocks.multiply_const_vcc((1/math.sqrt(self.fft_len), ))
        self.connect_blocks()
Exemplo n.º 13
0
    def __init__(self, len_tag_key, fft_len, cp_len, occupied_carriers,
                 pilot_symbols, pilot_carriers, sync_words):
        gr.hier_block2.__init__(self, "adaptive_ofdm_tx_bc",
                                gr.io_signature(1, 1, gr.sizeof_char),
                                gr.io_signature(1, 1, gr.sizeof_gr_complex))

        self.len_tag_key = len_tag_key
        self.fft_len = fft_len
        self.cp_len = cp_len
        self.occupied_carriers = occupied_carriers
        self.pilot_carriers = pilot_carriers
        self.pilot_symbols = pilot_symbols
        self.sync_words = sync_words

        self.select_adaptive_mod()
        self.create_header_blocks()
        self.create_payload_blocks()
        self.tagged_stream_mux = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex, self.len_tag_key, 0)
        self.create_ofdm_blocks()
        self.multiply = blocks.multiply_const_vcc(
            (1 / math.sqrt(self.fft_len), ))
        self.connect_blocks()
Exemplo n.º 14
0
    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))
Exemplo n.º 15
0
    def __init__(self):
        gr.top_block.__init__(self, "Full Ofdm")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Full Ofdm")
        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", "full_ofdm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word3 = sync_word3 = [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_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.request_seq = request_seq = (1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
        self.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_0 = header_formatter_0 = howto.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(), header_split=False, scramble_header=False)
        self.header_formatter = header_formatter = howto.packet_header_ofdm(occupied_carriers, 1,packet_length_tag_key)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols)
        self.data = data = (16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20)
        self.acknowledgement_utb_seq = acknowledgement_utb_seq = (6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,6,7,8,9,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
        self.acknowledgement_end_utb_seq = acknowledgement_end_utb_seq = (16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16
        
        ,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17
        
        ,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18,19,20,16,17,18
        
        ,19,20,16,17,18,19,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
        
        ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
        
        ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
        
        ,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
        self.acknowledgement_end_btu_seq = acknowledgement_end_btu_seq = (11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,11,12,13,14,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
        self.acknowledgement_btu_seq = acknowledgement_btu_seq = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)

        ##################################################
        # Blocks
        ##################################################
        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)
        
        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*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.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.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.howto_user_device_debug_0 = howto.user_device_debug(data, 12345, packet_len, request_seq, acknowledgement_btu_seq, acknowledgement_utb_seq, acknowledgement_end_btu_seq, acknowledgement_end_utb_seq)
        self.howto_sc_fdma_packet_headergenerator_bb_0 = howto.sc_fdma_packet_headergenerator_bb(header_formatter.formatter(), "packet_len")
        self.howto_ofdm_serializer_vcc_0 = howto.ofdm_serializer_vcc(fft_len, length_tag_key, packet_length_tag_key, 0, "", True)
        self.howto_ofdm_outer_headerparser_bb_0 = howto.ofdm_outer_headerparser_bb(fft_len, occupied_carriers)
        self.howto_ofdm_frame_equalizer_vcvc_1 = howto.ofdm_frame_equalizer_vcvc(fft_len, 12345, pilot_carriers, pilot_symbols, fft_len/4, length_tag_key, True, 0)
        self.howto_ofdm_chanest_vcvc_0 = howto.ofdm_chanest_vcvc((sync_word1), (sync_word2), 6, 0, 3, False)
        self.howto_ofdm_carrier_allocator_cvc_0 = howto.ofdm_carrier_allocator_cvc(12, 1e-4, 1000000, 1e-11, fft_len, occupied_carriers, ((-21,-7,7,21),), ((1,1,1,-1),), (sync_word1,sync_word2), "packet_len")
        self.howto_header_payload_demux_0 = howto.header_payload_demux(
        	  8,
        	  fft_len,
        	  fft_len/4,
        	  "frame_len",
        	  "",
        	  True,
        	  gr.sizeof_gr_complex,
        	  "rx_time",
                  samp_rate,
                  (),
            )
        self.howto_base_station_core_0 = howto.base_station_core(data, packet_len, request_seq, acknowledgement_btu_seq, acknowledgement_utb_seq, acknowledgement_end_btu_seq, acknowledgement_end_utb_seq)
        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_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(fft_len, fft_len/4, False)
        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_0 = digital.ofdm_frame_equalizer_vcvc(header_equalizer.base(), fft_len/4, length_tag_key, True, 6)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(fft_len, fft_len+fft_len/4, rolloff, packet_length_tag_key)
        self.digital_crc32_bb_0_0 = digital.crc32_bb(True, packet_length_tag_key)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, packet_length_tag_key)
        self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(payload_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.channels_selective_fading_model_0 = channels.selective_fading_model( 8, 10.0/samp_rate, False, 4.0, 0, (0.0,0.1,1.3), (1,0.99,0.97), 64 )
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=0.01,
        	frequency_offset=0,
        	epsilon=1.0,
        	taps=(1.0, ),
        	noise_seed=0,
        	block_tags=True
        )
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, packet_length_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_debug_1 = blocks.tag_debug(gr.sizeof_char*1, "Rx Bytes", ""); self.blocks_tag_debug_1.set_display(True)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, payload_mod.bits_per_symbol(), packet_length_tag_key, False)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.015625, ))
        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.connect((self.channels_channel_model_0, 0), (self.channels_selective_fading_model_0, 0))
        self.connect((self.howto_sc_fdma_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.howto_base_station_core_0, 0), (self.digital_crc32_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.fft_vxx_0, 0), (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.howto_ofdm_carrier_allocator_cvc_0, 0), (self.fft_vxx_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.howto_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0))
        self.connect((self.howto_header_payload_demux_0, 1), (self.fft_vxx_1, 0))
        self.connect((self.fft_vxx_0_0, 0), (self.howto_ofdm_chanest_vcvc_0, 0))
        self.connect((self.howto_header_payload_demux_0, 0), (self.fft_vxx_0_0, 0))
        self.connect((self.channels_selective_fading_model_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.howto_header_payload_demux_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 0), (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 1), (self.howto_header_payload_demux_0, 1))
        self.connect((self.fft_vxx_1, 0), (self.howto_ofdm_frame_equalizer_vcvc_1, 0))
        self.connect((self.howto_ofdm_frame_equalizer_vcvc_1, 0), (self.howto_ofdm_serializer_vcc_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header, 0), (self.howto_ofdm_outer_headerparser_bb_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0), (self.digital_ofdm_serializer_vcc_header, 0))
        self.connect((self.howto_ofdm_chanest_vcvc_0, 0), (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.howto_ofdm_serializer_vcc_0, 0), (self.digital_constellation_decoder_cb_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_crc32_bb_0_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.howto_sc_fdma_packet_headergenerator_bb_0, 0))
        self.connect((self.howto_user_device_debug_0, 0), (self.howto_base_station_core_0, 0))
        self.connect((self.digital_crc32_bb_0_0, 0), (self.blocks_tag_debug_1, 0))
        self.connect((self.channels_selective_fading_model_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.channels_selective_fading_model_0, 0), (self.qtgui_freq_sink_x_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.howto_ofdm_outer_headerparser_bb_0, "header_data", self.howto_header_payload_demux_0, "header_data")
Exemplo n.º 16
0
    def __init__(self):
        gr.top_block.__init__(self, "Tx Stage6")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tx Stage6")
        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_stage6")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.psf_taps = psf_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0, eb, 15*sps*nfilts)

        self.thresh = thresh = 3
        self.taps_per_filt = taps_per_filt = len(psf_taps)/nfilts

        self.pld_const = pld_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()

        self.pld_const.gen_soft_dec_lut(8)

        self.hdr_format = hdr_format = digital.header_format_default(digital.packet_utils.default_access_code, thresh)


        self.hdr_const = hdr_const = digital.constellation_calcdist((digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()

        self.hdr_const.gen_soft_dec_lut(8)
        self.filt_delay = filt_delay = 1+(taps_per_filt-1)/2
        self.bps = bps = pld_const.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'Time')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'Freq')
        self.top_layout.addWidget(self.tab)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	400*sps, #size
        	sps, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.01)
        self.qtgui_time_sink_x_0.set_y_axis(-2, 2)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 15, 0, 'packet_len')
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2):
            if len(labels[i]) == 0:
                if(i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.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
        	sps, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          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.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  sps,
                  taps=(psf_taps),
        	  flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(filt_delay)

        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + 'hackrf=0' )
        self.osmosdr_sink_0.set_sample_rate(32)
        self.osmosdr_sink_0.set_center_freq(144e6, 0)
        self.osmosdr_sink_0.set_freq_corr(0, 0)
        self.osmosdr_sink_0.set_gain(10, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(20, 0)
        self.osmosdr_sink_0.set_antenna('ant0', 0)
        self.osmosdr_sink_0.set_bandwidth(0, 0)

        self.digital_protocol_formatter_async_0 = digital.protocol_formatter_async(hdr_format)
        self.digital_map_bb_1_0 = digital.map_bb((pld_const.pre_diff_code()))
        self.digital_map_bb_1 = digital.map_bb((hdr_const.pre_diff_code()))
        self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc((pld_const.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((hdr_const.points()), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, 'packet_len', 0)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '52001', 10, False)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(8, pld_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, hdr_const.bits_per_symbol(), 'packet_len', False, gr.GR_MSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.5, ))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.digital_crc32_async_bb_1, 'in'))
        self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.digital_protocol_formatter_async_0, 'in'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'payload'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.digital_protocol_formatter_async_0, 'header'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_map_bb_1_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.pfb_arb_resampler_xxx_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_map_bb_1, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_map_bb_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))
Exemplo n.º 17
0
    def __init__(self,
                 freq=5000,
                 hdr_format=digital.header_format_default(
                     digital.packet_utils.default_access_code, 0),
                 input_file="test_input.txt"):
        gr.top_block.__init__(self, "Qpsk Tx 0217")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Qpsk Tx 0217")
        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", "qpsk_tx_0217")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.freq = freq
        self.hdr_format = hdr_format
        self.input_file = input_file

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 50
        self.nfilts = nfilts = 32
        self.excess_bw = excess_bw = 1
        self.vec = vec = [
            0x96, 0x85, 0x81, 0x4a, 0xd7, 0x2e, 0x73, 0xe4, 0x33, 0x33, 0x47,
            0xfc, 0x67, 0x3f, 0x72, 0x23, 0x44, 0x15, 0xc0, 0x04, 0x09, 0x13,
            0x59, 0x77
        ]
        self.samp_rate = samp_rate = 44100
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), excess_bw, 11 * sps * nfilts)

        self.qpsk = qpsk = digital.constellation_qpsk().base()

        self.excess_bw_0 = excess_bw_0 = 1
        self.carrier_freq = carrier_freq = freq

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "float" == "float" or "float" == "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.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, 'len_key')
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=qpsk,
            differential=True,
            samples_per_symbol=sps,
            pre_diff_code=True,
            excess_bw=0.7,
            verbose=False,
            log=False,
        )
        self.blocks_wavfile_sink_0 = blocks.wavfile_sink(
            '/home/peter/Desktop/out.wav', 1, samp_rate, 8)
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            vec, True, 1, [])
        self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, 'len_key', 0)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, 'len_key', 0)
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 119, "len_key")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, len(vec), "len_key")
        self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vff(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.6, ))
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/home/peter/Desktop/acoustic_radio/Testings/test_input.txt', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0_0 = analog.sig_source_f(
            samp_rate, analog.GR_SIN_WAVE, carrier_freq, -1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_f(
            samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_wavfile_sink_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_mux_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.blocks_tagged_stream_mux_0_0, 1))
        self.connect((self.blocks_tagged_stream_mux_0_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
Exemplo n.º 18
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
              ):
     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
     n_sync_words = 1
     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,]
     self.sync_word2 = ()
     if sync_word2 is None:
         self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers)
     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)
         n_sync_words = 2
         self.sync_words.append(self.sync_word2)
     ### 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
     )
     header_gen = digital.packet_headergenerator_bb(formatter_object.base(), self.packet_length_tag_key)
     header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.packet_length_tag_key)
     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())
     self.connect(
         crc,
         blocks.repack_bits_bb(
             8, # Unpack 8 bits per byte
             bps_payload,
             self.packet_length_tag_key
         ),
         payload_mod,
         (header_payload_mux, 1)
     )
     ### Create OFDM frame ################################################
     allocator = digital.ofdm_carrier_allocator_cvc(
         self.fft_len,
         occupied_carriers=self.occupied_carriers,
         pilot_carriers=self.pilot_carriers,
         pilot_symbols=self.pilot_symbols,
         sync_words=self.sync_words,
         len_tag_key=self.packet_length_tag_key
     )
     ffter = fft.fft_vcc(
             self.fft_len,
             False, # Inverse FFT
             (), # No window
             True # Shift
     )
     cyclic_prefixer = digital.ofdm_cyclic_prefixer(
         self.fft_len,
         self.fft_len+self.cp_len,
         rolloff,
         self.packet_length_tag_key
     )
     self.connect(header_payload_mux, allocator, ffter, cyclic_prefixer, self)
     if debug_log:
         self.connect(allocator,         blocks.file_sink(8*64, 'tx-post-allocator.dat'))
         self.connect(cyclic_prefixer,   blocks.file_sink(8,    'tx-signal.dat'))
Exemplo n.º 19
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))
Exemplo n.º 20
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))
Exemplo n.º 21
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.down_sampling = down_sampling = 16
        self.sample_rate = sample_rate = 250e3*down_sampling
        self.preamble_len_tag = preamble_len_tag = gr.tag_utils.python_to_tag((0, pmt.intern("packet_len"), pmt.from_long(8), pmt.intern("src")))
        self.f1_bp_taps = f1_bp_taps = [-0.008489873260259628, 0.017516516149044037, -0.02309376560151577, 3.1378305752533504e-17, 0.06292477995157242, -0.12457011640071869, 0.1126808300614357, -3.387264241990756e-17, -0.14707811176776886, 0.21481703221797943, -0.14707811176776886, -3.387264241990756e-17, 0.1126808300614357, -0.12457011640071869, 0.06292477995157242, 3.1378305752533504e-17, -0.02309376560151577, 0.017516516149044037, -0.008489873260259628]
        self.f0_bp_taps = f0_bp_taps =  [0.008489873260259628, 0.017516516149044037, 0.02309376560151577, -1.1766864243609758e-17, -0.06292477995157242, -0.12457011640071869, -0.1126808300614357, 3.387264241990756e-17, 0.14707811176776886, 0.21481703221797943, 0.14707811176776886, 3.387264241990756e-17, -0.1126808300614357, -0.12457011640071869, -0.06292477995157242, -1.1766864243609758e-17, 0.02309376560151577, 0.017516516149044037, 0.008489873260259628]

        ##################################################
        # Blocks
        ##################################################
        self.rad1o_id_compare_select_fb_0 = rad1o_id.compare_select_fb()
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
        	1024, #size
        	sample_rate/down_sampling, #samp_rate
        	"", #name
        	2 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        
        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")
        
        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(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*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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
                gr.sizeof_char,
                0,
                qtgui.NUM_GRAPH_HORIZ,
        	1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        units = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])
        
        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	sample_rate/down_sampling, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)
        
        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()
        
        if complex == type(float()):
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])
        
        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.fir_filter_xxx_1_0 = filter.fir_filter_fff(down_sampling/2, (1, ))
        self.fir_filter_xxx_1_0.declare_sample_delay(0)
        self.fir_filter_xxx_1 = filter.fir_filter_fff(down_sampling/2, (1, ))
        self.fir_filter_xxx_1.declare_sample_delay(0)
        self.fir_filter_xxx_0_0 = filter.fir_filter_ccc(down_sampling/2, (f1_bp_taps))
        self.fir_filter_xxx_0_0.declare_sample_delay(0)
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(down_sampling/2, (f0_bp_taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(([0.5, 1.5]), 1)
        self.channels_channel_model_0 = channels.channel_model(
        	noise_voltage=100e-2,
        	frequency_offset=1e-4,
        	epsilon=1.0,
        	taps=(1.0 + 1.0j, ),
        	noise_seed=0,
        	block_tags=True
        )
        self.blocks_vector_source_x_1 = blocks.vector_source_b((0,0), True, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b([0,0], True, 1, [preamble_len_tag])
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_char*1, "packet_len", 0)
        self.blocks_tagged_stream_align_1 = blocks.tagged_stream_align(gr.sizeof_char*1, "packet_len")
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "packet_length", ""); self.blocks_tag_debug_0.set_display(False)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 64, "packet_len")
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, 16)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, ))
        self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(1)
        self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(2*pi/4)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.analog_frequency_modulator_fc_0, 0), (self.channels_channel_model_0, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.fir_filter_xxx_1, 0))    
        self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.fir_filter_xxx_1_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fir_filter_xxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.fir_filter_xxx_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_freq_sink_x_0, 0))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_repeat_0, 0))    
        self.connect((self.blocks_repeat_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))    
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_mux_0, 1))    
        self.connect((self.blocks_tagged_stream_align_1, 0), (self.blocks_tagged_stream_mux_0, 0))    
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_tag_debug_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_tagged_stream_align_1, 0))    
        self.connect((self.blocks_vector_source_x_1, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
        self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.analog_frequency_modulator_fc_0, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0))    
        self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0))    
        self.connect((self.fir_filter_xxx_0_0, 0), (self.qtgui_time_sink_x_0, 1))    
        self.connect((self.fir_filter_xxx_1, 0), (self.rad1o_id_compare_select_fb_0, 0))    
        self.connect((self.fir_filter_xxx_1_0, 0), (self.rad1o_id_compare_select_fb_0, 1))    
        self.connect((self.rad1o_id_compare_select_fb_0, 0), (self.qtgui_number_sink_0, 0))    
Exemplo n.º 22
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 = digital.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'))
Exemplo n.º 23
0
    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))
Exemplo n.º 24
0
    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))    
Exemplo n.º 25
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM_TX_RX_1")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM_TX_RX_1")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "OFDM_TX_RX_1")

        try:
            if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
                self.restoreGeometry(
                    self.settings.value("geometry").toByteArray())
            else:
                self.restoreGeometry(self.settings.value("geometry"))
        except:
            pass

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            list(range(-26, -21)) + list(range(-20, -7)) + list(range(-6, 0)) +
            list(range(1, 7)) + list(range(8, 21)) + list(range(22, 27)), )
        self.length_tag_key_rx = length_tag_key_rx = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1,
            1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1,
            1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1,
            -1, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 1000000
        self.rolloff = rolloff = 0
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.packet_len = packet_len = 30
        self.length_tag_key = length_tag_key = "packet_len"
        self.header_len = header_len = 10
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key_rx,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=[],
            ),
            '',
        )
        self.uhd_usrp_sink_0.set_center_freq(3.555e9, 0)
        self.uhd_usrp_sink_0.set_gain(31, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_bandwidth(0.5e6, 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.fft_vxx_0 = fft.fft_vcc(fft_len, False, (), True, 1)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            digital.header_format_ofdm(
                occupied_carriers,
                1,
                length_tag_key,
            ), length_tag_key)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + 16, rolloff, length_tag_key)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key, True)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, length_tag_key)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(0.05)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            '/local/repository/gnuradio/file_to_transmit.txt', False, 0, 0)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
Exemplo n.º 26
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")
        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))
Exemplo n.º 27
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")
Exemplo n.º 28
0
    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, 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))    
Exemplo n.º 30
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))
Exemplo n.º 31
0
 def __init__(self, len_tag_key, enable_crc):
     gr.hier_block2.__init__(self,
         "frame_encoder",
         gr.io_signature(1, 1, gr.sizeof_char),  # Input signature
         gr.io_signature(1, 1, gr.sizeof_char)) # Output signature
     
     self.len_tag_key = len_tag_key
     
     # For header creation
     self.digital_packet_headergenerator_bb_default_0 \
             = digital.packet_headergenerator_bb(32, self.len_tag_key)
     
     # Place CRC 32bit after payload
     if enable_crc:
         self.digital_crc32_bb_0 = digital.crc32_bb(False, self.len_tag_key, 
                                                    True)
     
     # Tagged stream blocks
     
     # Combine access code, header and payload
     self.blocks_tagged_stream_mux_0  \
             = blocks.tagged_stream_mux(gr.sizeof_char*1, self.len_tag_key, 0)
     
     # Multiply Size in payload stream
     #self.blocks_tagged_stream_multiply_length_0 \
     #        = blocks.tagged_stream_multiply_length(gr.sizeof_char*1, 
     #                                               self.len_tag_key, 8)
     
     self.blocks_stream_to_tagged_stream_1 \
             = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 64, 
                                              self.len_tag_key)
     
     # Repacker
     self.blocks_repack_bits_bb_garbage  \
         = blocks.repack_bits_bb(8, 1, "", False, gr.GR_MSB_FIRST)
     self.blocks_repack_bits_bb_access  \
         = blocks.repack_bits_bb(8, 1, "", False, gr.GR_MSB_FIRST)
     self.blocks_repack_bits_bb_payload  \
         = blocks.repack_bits_bb(8, 1, len_tag_key, False, gr.GR_MSB_FIRST)
     self.blocks_repack_bits_bb_complete  \
         = blocks.repack_bits_bb(1, 8, "", False, gr.GR_MSB_FIRST)
     
     self.access_code_vector  \
         = blocks.vector_source_b((172, 221, 164, 226,242, 140, 32, 252), 
                                   True, 1, [])
     
     # Debug
     # Print complete Payload with packet
     #self.blocks_message_debug_0 = blocks.message_debug()
     #self.blocks_tagged_stream_to_pdu_0 \
     #    = blocks.tagged_stream_to_pdu(blocks.byte_t, len_tag_key)
     
     
     # Garbage bytes
     self.garbage_vector  \
         = blocks.vector_source_b((159, 200), 
                                   True, 1, [])
     self.stream_to_tagged_garbage \
             = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 16, 
                                              self.len_tag_key)
     
     ##################################################
     # Connections
     ##################################################
     
     # Garbage up front
     
     self.connect((self.garbage_vector, 0), 
                  (self.blocks_repack_bits_bb_garbage, 0))
     
     self.connect((self.blocks_repack_bits_bb_garbage, 0), 
                  (self.stream_to_tagged_garbage, 0))
     
     self.connect((self.stream_to_tagged_garbage, 0), 
                  (self.blocks_tagged_stream_mux_0, 0))
     
     # And at the back
     self.connect((self.stream_to_tagged_garbage, 0), 
                  (self.blocks_tagged_stream_mux_0, 4))
     
     # Access code path
     
     self.connect((self.access_code_vector, 0), 
                  (self.blocks_repack_bits_bb_access, 0))
     
     self.connect((self.blocks_repack_bits_bb_access, 0), 
                  (self.blocks_stream_to_tagged_stream_1, 0))
     
     self.connect((self.blocks_stream_to_tagged_stream_1, 0), 
                  (self.blocks_tagged_stream_mux_0, 1))
     
     # Payload path
     
     if enable_crc:
         self.connect((self.digital_crc32_bb_0, 0), 
                      (self.blocks_repack_bits_bb_payload, 0))
     
     
     self.connect((self.blocks_repack_bits_bb_payload, 0), 
                  (self.blocks_tagged_stream_mux_0, 3))
     if enable_crc:
         self.connect((self.digital_crc32_bb_0, 0), 
                      (self.digital_packet_headergenerator_bb_default_0, 0))
     
     # Debug
     # Print complete packet with payload
     #if enable_crc:
     #    self.connect((self.digital_crc32_bb_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
     #else:
     #    self.connect((self, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
     
     #self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), 
     #                 (self.blocks_message_debug_0, 'print_pdu'))
         
     
     
     # Header path
     
     self.connect((self.digital_packet_headergenerator_bb_default_0, 0), 
                  (self.blocks_tagged_stream_mux_0, 2))
     
     # Output
     
     self.connect((self.blocks_tagged_stream_mux_0, 0), 
                  (self.blocks_repack_bits_bb_complete, 0))
     
     # Connect Input and out
     if enable_crc:
         self.connect((self,0), (self.digital_crc32_bb_0, 0))
     else:
         self.connect((self,0), (self.digital_packet_headergenerator_bb_default_0, 0))
         self.connect((self,0), (self.blocks_repack_bits_bb_payload, 0))
     
     self.connect((self.blocks_repack_bits_bb_complete, 0), (self,0))
Exemplo n.º 32
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")
Exemplo n.º 33
0
    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))
Exemplo n.º 34
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))    
Exemplo n.º 35
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 = digital.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'))
Exemplo n.º 36
0
 def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
              frame_length_tag_key=_def_frame_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
              ):
     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.fft_len           = fft_len
     self.cp_len            = cp_len
     self.frame_length_tag_key    = frame_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
     n_sync_words = 1
     header_constellation  = _get_constellation(bps_header)
     header_mod = digital.chunks_to_symbols_bc(header_constellation.points())
     self.sync_word1 = sync_word1
     if sync_word1 is None:
         self.sync_word1 = _make_sync_word(fft_len, occupied_carriers, header_constellation)
     else:
         if len(sync_word1) != self.fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
     total_sync_word = self.sync_word1
     self.sync_word2 = ()
     if sync_word2 is not None:
         if len(sync_word2) != fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
         self.sync_word2 = sync_word2
         n_sync_words = 2
         total_sync_word = sync_word1 + sync_word2
     crc = digital.crc32_bb(False, self.frame_length_tag_key)
     formatter_object = digital.packet_header_ofdm(
         occupied_carriers, 1, "", "", "",
         bps_header
     )
     header_gen = digital.packet_headergenerator_bb(formatter_object.base())
     header_payload_mux = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, self.frame_length_tag_key)
     self.connect(self, crc, header_gen, header_mod, (header_payload_mux, 0))
     payload_constellation = _get_constellation(bps_payload)
     payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points())
     self.connect(
         crc,
         blocks.repack_bits_bb(8, bps_payload, frame_length_tag_key),
         payload_mod,
         (header_payload_mux, 1)
     )
     self.connect(payload_mod, gr.tag_debug(gr.sizeof_gr_complex, "pmod"))
     sync_word_gen = gr.vector_source_c(
         total_sync_word, True, self.fft_len,
         tagged_streams.make_lengthtags((n_sync_words,), (0,), self.frame_length_tag_key)
     )
     allocator = digital.ofdm_carrier_allocator_cvc(
         self.fft_len,
         occupied_carriers=self.occupied_carriers,
         pilot_carriers=self.pilot_carriers,
         pilot_symbols=self.pilot_symbols,
         len_tag_key=self.frame_length_tag_key
     )
     syncword_data_mux  = blocks.tagged_stream_mux(gr.sizeof_gr_complex*self.fft_len, self.frame_length_tag_key)
     self.connect(sync_word_gen, (syncword_data_mux, 0))
     self.connect(header_payload_mux, allocator, (syncword_data_mux, 1))
     ffter = fft.fft_vcc(self.fft_len, False, (), False)
     cyclic_prefixer = digital.ofdm_cyclic_prefixer(
         self.fft_len,
         self.fft_len+self.cp_len,
         rolloff,
         self.frame_length_tag_key
     )
     self.connect(syncword_data_mux, ffter, cyclic_prefixer, self)
Exemplo n.º 37
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))
Exemplo n.º 38
0
    def __init__(self):
        gr.top_block.__init__(self, "Novo")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Novo")
        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", "novo")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 2
        self.nfilts = nfilts = 32
        self.eb = eb = 0.22

        self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0, eb, 5 * sps * nfilts)

        self.Const_HDR = Const_HDR = digital.constellation_calcdist(
            (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()

        self.Const_HDR.gen_soft_dec_lut(8)
        self.taps_per_filt = taps_per_filt = len(tx_rrc_taps) / nfilts
        self.rxmod = rxmod = digital.generic_mod(Const_HDR, False, sps, True,
                                                 eb, False, False)
        self.preamble = preamble = [
            0xac, 0xdd, 0xa4, 0xe2, 0xf2, 0x8c, 0x20, 0xfc
        ]
        self.mark_delays = mark_delays = [0, 0, 34, 56, 87, 119]
        self.snc_threshold = snc_threshold = 0.9
        self.samp_rate = samp_rate = 32000

        self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, sps * nfilts, 1.0, eb, 11 * sps * nfilts)

        self.packet_len_tag_key = packet_len_tag_key = "packet_length"
        self.packet_len = packet_len = 100
        self.ntaps = ntaps = len(tx_rrc_taps)
        self.noise_voltage = noise_voltage = 1
        self.modulated_sync_word = modulated_sync_word = digital.modulate_vector_bc(
            rxmod.to_basic_block(), (preamble), ([1]))
        self.mark_delay = mark_delay = mark_delays[sps]

        self.hdr_format = hdr_format = digital.header_format_default(
            digital.packet_utils.default_access_code, 1, 1)

        self.freq_offset = freq_offset = 0
        self.filt_delay = filt_delay = 1 + (taps_per_filt - 1) / 2

        self.enc_hdr = enc_hdr = fec.dummy_encoder_make(8000)

        self.enc = enc = fec.dummy_encoder_make(8000)

        self.dec_hdr = dec_hdr = fec.dummy_decoder.make(8000)

        self.Const_PLD = Const_PLD = digital.constellation_calcdist(
            (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base()

        self.Const_PLD.gen_soft_dec_lut(8)

        ##################################################
        # Blocks
        ##################################################
        self._noise_voltage_range = Range(0, 8, .05, 1, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range,
                                              self.set_noise_voltage,
                                              'Noise Amplitude',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_win)
        self._freq_offset_range = Range(-30, 30, .1, 0, 200)
        self._freq_offset_win = RangeWidget(
            self._freq_offset_range, self.set_freq_offset,
            'Frequency Offset (Multiples of Sub-carrier spacing)',
            "counter_slider", float)
        self.top_grid_layout.addWidget(self._freq_offset_win)
        self._snc_threshold_range = Range(0, 1, .05, 0.9, 200)
        self._snc_threshold_win = RangeWidget(self._snc_threshold_range,
                                              self.set_snc_threshold,
                                              'S&C Threshold',
                                              "counter_slider", float)
        self.top_grid_layout.addWidget(self._snc_threshold_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
            packet_len * 3,  #size
            samp_rate,  #samp_rate
            'Tx Data',  #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, 256)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, '')
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(True)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            packet_len * 2,  #size
            samp_rate,  #samp_rate
            'Rx Data',  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, 'packet_length_tag_key')
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(True)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            'Rx Spectrum',  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-60, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['Rx Spectrum', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(
            sps, taps=(tx_rrc_taps), flt_size=nfilts)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(filt_delay)

        self.digital_protocol_parser_b_0 = digital.protocol_parser_b(
            hdr_format)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, packet_len_tag_key)
        self.digital_pfb_clock_sync_xxx_0_1 = digital.pfb_clock_sync_ccf(
            sps, 6.28 / 400.0, (rx_rrc_taps), nfilts, nfilts / 2, 1.5, 1)
        self.digital_map_bb_1_0 = digital.map_bb((Const_PLD.pre_diff_code()))
        self.digital_map_bb_1 = digital.map_bb((Const_HDR.pre_diff_code()))
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            hdr_format.header_nbits() / Const_HDR.bits_per_symbol(),
            1,
            0,
            "payload symbols",
            "time_est",
            True,
            gr.sizeof_gr_complex,
            "rx_time",
            sps,
            "",
            0,
        )
        self.digital_corr_est_cc_0_0 = digital.corr_est_cc(
            (modulated_sync_word), 1, mark_delay, 0.999)
        self.digital_constellation_soft_decoder_cf_0_1 = digital.constellation_soft_decoder_cf(
            Const_PLD)
        self.digital_constellation_soft_decoder_cf_0_0 = digital.constellation_soft_decoder_cf(
            Const_HDR)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (Const_PLD.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (Const_HDR.points()), 1)
        self.digital_burst_shaper_xx_0_0 = digital.burst_shaper_cc(
            (firdes.window(firdes.WIN_HANN, 20, 0)), 0, filt_delay, True,
            packet_len_tag_key)
        (self.digital_burst_shaper_xx_0_0).set_block_alias("burst_shaper0")
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0,
            frequency_offset=freq_offset * 1.0 / packet_len,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=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, packet_len_tag_key, 0)
        self.blocks_tagged_stream_multiply_length_0_1 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, packet_len_tag_key, sps)
        self.blocks_tag_debug_0_0_0 = blocks.tag_debug(gr.sizeof_char * 1,
                                                       'TAGGED', "")
        self.blocks_tag_debug_0_0_0.set_display(True)
        self.blocks_tag_debug_0_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1,
                                                     'MUX', "")
        self.blocks_tag_debug_0_0.set_display(True)
        self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, packet_len_tag_key)
        self.blocks_repack_bits_bb_1_0 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb(
            1, 8, "", False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, Const_PLD.bits_per_symbol(), packet_len_tag_key, False,
            gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            8, Const_HDR.bits_per_symbol(), packet_len_tag_key, False,
            gr.GR_MSB_FIRST)
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1, '/home/andre/Desktop/trasmit_1_mb.txt', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0_0_0 = blocks.file_sink(
            gr.sizeof_char * 1, 'depois.txt', False)
        self.blocks_file_sink_0_0_0_0.set_unbuffered(False)
        self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_protocol_parser_b_0, 'info'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.connect((self.blocks_char_to_float_1_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_1_0_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_stream_to_tagged_stream_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_map_bb_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_map_bb_1_0, 0))
        self.connect((self.blocks_repack_bits_bb_1, 0),
                     (self.blocks_char_to_float_1_0, 0))
        self.connect((self.blocks_repack_bits_bb_1, 0),
                     (self.blocks_file_sink_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_1_0, 0),
                     (self.digital_protocol_parser_b_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_char_to_float_1_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0_1, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.blocks_tag_debug_0_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_burst_shaper_xx_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.digital_corr_est_cc_0_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_repack_bits_bb_1, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0),
                     (self.blocks_repack_bits_bb_1_0, 0))
        self.connect((self.digital_burst_shaper_xx_0_0, 0),
                     (self.pfb_arb_resampler_xxx_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_soft_decoder_cf_0_0, 0),
                     (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_0_1, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_corr_est_cc_0_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_1, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.digital_constellation_soft_decoder_cf_0_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.digital_constellation_soft_decoder_cf_0_1, 0))
        self.connect((self.digital_map_bb_1, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.digital_map_bb_1_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_1, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_tag_debug_0_0_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0_1, 0))
Exemplo n.º 39
0
    def __init__(self):
        gr.top_block.__init__(self, "Simu Chaine")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Simu Chaine")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "simu_chaine")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.sync_word2 = sync_word2 = [
            0j, 0j, 0j, 0j, 0j, 0j, (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (-1 + 0j), (1 + 0j), (-1 + 0j), 0j, (1 + 0j), (-1 + 0j),
            (1 + 0j), (1 + 0j), (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j),
            (1 + 0j), (-1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (1 + 0j),
            (-1 + 0j), (1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j), (-1 + 0j),
            0j, 0j, 0j, 0j, 0j
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.samp_rate = samp_rate = 5000000
        self.rolloff = rolloff = 0
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, payload_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols, 1)
        self.packet_len = packet_len = 96
        self.header_formatter = header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            n_syms=1,
            len_tag_key=packet_length_tag_key,
            frame_len_tag_key=length_tag_key,
            bits_per_header_sym=header_mod.bits_per_symbol(),
            bits_per_payload_sym=payload_mod.bits_per_symbol(),
            scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len, header_mod.base(), occupied_carriers, pilot_carriers,
            pilot_symbols)

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("serial=30CEEB2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(2.492e9, 0)
        self.uhd_usrp_source_0.set_gain(40, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("serial=30CEECB", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            packet_length_tag_key,
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(2.492e9, 0)
        self.uhd_usrp_sink_0.set_gain(100, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.qtgui_time_sink_x_2 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_2.set_update_time(0.10)
        self.qtgui_time_sink_x_2.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_2.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_2.enable_tags(-1, True)
        self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_2.enable_autoscale(False)
        self.qtgui_time_sink_x_2.enable_grid(False)
        self.qtgui_time_sink_x_2.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_2.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_2.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_2.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_2.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_2.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_2.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_2.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_2.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_2_win = sip.wrapinstance(
            self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_2_win)
        self.qtgui_time_sink_x_1 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "Rx",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_1.set_update_time(0.10)
        self.qtgui_time_sink_x_1.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_1.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_1.enable_tags(-1, True)
        self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_1.enable_autoscale(False)
        self.qtgui_time_sink_x_1.enable_grid(False)
        self.qtgui_time_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_1.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_1.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_1_win = sip.wrapinstance(
            self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_1_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(2 * 1):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.pir_print_bytes_bb_0 = pir.print_bytes_bb()
        self.fft_vxx_1 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0 = fft.fft_vcc(fft_len, False, (()), True, 1)
        self.fft_vxx_0 = fft.fft_vcc(fft_len, True, (()), True, 1)
        self.digital_packet_headerparser_b_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(
            header_formatter.formatter(), packet_length_tag_key)
        self.digital_ofdm_sync_sc_cfb_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len / 4, False)
        self.digital_ofdm_serializer_vcc_payload = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, "", True)
        self.digital_ofdm_serializer_vcc_header = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, "", 0, "", True)
        self.digital_ofdm_frame_equalizer_vcvc_1 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len / 4, length_tag_key, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len / 4, length_tag_key, True, 1)
        self.digital_ofdm_cyclic_prefixer_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len / 4, rolloff, packet_length_tag_key)
        self.digital_ofdm_chanest_vcvc_0 = digital.ofdm_chanest_vcvc(
            (sync_word1), (sync_word2), 1, 0, 3, False)
        self.digital_ofdm_carrier_allocator_cvc_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), packet_length_tag_key)
        self.digital_header_payload_demux_0 = digital.header_payload_demux(
            3,
            fft_len,
            fft_len / 4,
            length_tag_key,
            "",
            True,
            gr.sizeof_gr_complex,
            "rx_time",
            samp_rate,
            (),
        )
        self.digital_crc32_bb_0_0 = digital.crc32_bb(False,
                                                     packet_length_tag_key,
                                                     True)
        self.digital_crc32_bb_0 = digital.crc32_bb(True, packet_length_tag_key,
                                                   True)
        self.digital_corr_est_cc_0 = digital.corr_est_cc(
            ((0.00000 - 0.00000j, -0.23756 + 0.06817j, 0.02455 - 0.06790j,
              -0.02923 + 0.05414j, 0.00701 - 0.10558j, 0.07080 - 0.00739j,
              0.04334 + 0.00660j, -0.11691 + 0.08759j, 0.09375 + 0.06250j,
              0.04313 - 0.10143j, 0.00862 - 0.03317j, -0.05702 + 0.07170j,
              -0.09857 - 0.09157j, 0.02654 + 0.03204j, -0.03675 - 0.04537j,
              0.06443 + 0.17533j, 0.04419 + 0.00000j, 0.06443 - 0.17533j,
              -0.03675 + 0.04537j, 0.02654 - 0.03204j, -0.09857 + 0.09157j,
              -0.05702 - 0.07170j, 0.00862 + 0.03317j, 0.04313 + 0.10143j,
              0.09375 - 0.06250j, -0.11691 - 0.08759j, 0.04334 - 0.00660j,
              0.07080 + 0.00739j, 0.00701 + 0.10558j, -0.02923 - 0.05414j,
              0.02455 + 0.06790j, -0.23756 - 0.06817j, 0.00000 + 0.00000j,
              0.23756 - 0.06817j, -0.02455 + 0.06790j, 0.02923 - 0.05414j,
              -0.00701 + 0.10558j, -0.07080 + 0.00739j, -0.04334 - 0.00660j,
              0.11691 - 0.08759j, -0.09375 - 0.06250j, -0.04313 + 0.10143j,
              -0.00862 + 0.03317j, 0.05702 - 0.07170j, 0.09857 + 0.09157j,
              -0.02654 - 0.03204j, 0.03675 + 0.04537j, -0.06443 - 0.17533j,
              -0.04419 + 0.00000j, -0.06443 + 0.17533j, 0.03675 - 0.04537j,
              -0.02654 + 0.03204j, 0.09857 - 0.09157j, 0.05702 + 0.07170j,
              -0.00862 - 0.03317j, -0.04313 - 0.10143j, -0.09375 + 0.06250j,
              0.11691 + 0.08759j, -0.04334 + 0.00660j, -0.07080 - 0.00739j,
              -0.00701 - 0.10558j, 0.02923 + 0.05414j, -0.02455 - 0.06790j,
              0.23756 + 0.06817j, 0.00000 - 0.00000j, -0.23756 + 0.06817j,
              0.02455 - 0.06790j, -0.02923 + 0.05414j, 0.00701 - 0.10558j,
              0.07080 - 0.00739j, 0.04334 + 0.00660j, -0.11691 + 0.08759j,
              0.09375 + 0.06250j, 0.04313 - 0.10143j, 0.00862 - 0.03317j,
              -0.05702 + 0.07170j, -0.09857 - 0.09157j, 0.02654 + 0.03204j,
              -0.03675 - 0.04537j, 0.06443 + 0.17533j, 0.06250 + 0.03125j,
              -0.10790 - 0.08255j, 0.00182 + 0.03337j, 0.09586 - 0.07711j,
              0.06872 + 0.05573j, 0.00373 + 0.04257j, -0.03565 - 0.03853j,
              -0.14193 + 0.01821j, -0.15089 - 0.03504j, 0.14492 - 0.01154j,
              0.07984 + 0.05798j, -0.06544 - 0.02403j, 0.10927 - 0.05236j,
              0.14303 + 0.12879j, -0.04601 - 0.13003j, -0.11594 + 0.05444j,
              -0.06250 + 0.00000j, -0.11594 - 0.05444j, -0.04601 + 0.13003j,
              0.14303 - 0.12879j, 0.10927 + 0.05236j, -0.06544 + 0.02403j,
              0.07984 - 0.05798j, 0.14492 + 0.01154j, -0.15089 + 0.03504j,
              -0.14193 - 0.01821j, -0.03565 + 0.03853j, 0.00373 - 0.04257j,
              0.06872 - 0.05573j, 0.09586 + 0.07711j, 0.00182 - 0.03337j,
              -0.10790 + 0.08255j, 0.06250 - 0.03125j, -0.00527 - 0.11799j,
              0.00182 + 0.05304j, 0.05923 + 0.02687j, -0.09460 + 0.11347j,
              0.06227 - 0.14667j, -0.03565 + 0.03377j, -0.10488 - 0.05448j,
              0.02589 + 0.09754j, 0.06134 - 0.07480j, 0.07984 + 0.06226j,
              -0.02766 + 0.02419j, 0.04162 - 0.02844j, -0.09425 - 0.14799j,
              -0.04601 + 0.09145j, 0.09289 + 0.12172j, -0.06250 + 0.00000j,
              0.09289 - 0.12172j, -0.04601 - 0.09145j, -0.09425 + 0.14799j,
              0.04162 + 0.02844j, -0.02766 - 0.02419j, 0.07984 - 0.06226j,
              0.06134 + 0.07480j, 0.02589 - 0.09754j, -0.10488 + 0.05448j,
              -0.03565 - 0.03377j, 0.06227 + 0.14667j, -0.09460 - 0.11347j,
              0.05923 - 0.02687j, 0.00182 - 0.05304j, -0.00527 + 0.11799j,
              0.06250 + 0.03125j, -0.10790 - 0.08255j, 0.00182 + 0.03337j,
              0.09586 - 0.07711j, 0.06872 + 0.05573j, 0.00373 + 0.04257j,
              -0.03565 - 0.03853j, -0.14193 + 0.01821j, -0.15089 - 0.03504j,
              0.14492 - 0.01154j, 0.07984 + 0.05798j, -0.06544 - 0.02403j,
              0.10927 - 0.05236j, 0.14303 + 0.12879j, -0.04601 - 0.13003j,
              -0.11594 + 0.05444j)), 1, 0, 0.999999999)
        self.digital_constellation_decoder_cb_1 = digital.constellation_decoder_cb(
            payload_mod.base())
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (payload_mod.points()), 1)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (header_mod.points()), 1)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, "packet_len", 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 True)
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), packet_length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True,
            gr.GR_LSB_FIRST)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1, "/home/rhidra/pir/test/test_modules/out.txt",
            False)
        self.blocks_file_sink_1.set_unbuffered(False)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                           fft_len + fft_len / 4)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 255, 1000)), True)
        self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_packet_headerparser_b_0, 'header_data'),
                         (self.digital_header_payload_demux_0, 'header_data'))
        self.connect((self.analog_frequency_modulator_fc_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.digital_crc32_bb_0_0, 0))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.pir_print_bytes_bb_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_corr_est_cc_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.digital_header_payload_demux_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.qtgui_time_sink_x_2, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.digital_packet_headerparser_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.digital_corr_est_cc_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.digital_crc32_bb_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.digital_crc32_bb_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_crc32_bb_0_0, 0),
                     (self.digital_packet_headergenerator_bb_0, 0))
        self.connect((self.digital_header_payload_demux_0, 0),
                     (self.fft_vxx_0, 0))
        self.connect((self.digital_header_payload_demux_0, 1),
                     (self.fft_vxx_1, 0))
        self.connect((self.digital_ofdm_carrier_allocator_cvc_0, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0, 0),
                     (self.digital_ofdm_serializer_vcc_header, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_1, 0),
                     (self.digital_ofdm_serializer_vcc_payload, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload, 0),
                     (self.digital_constellation_decoder_cb_1, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 0),
                     (self.analog_frequency_modulator_fc_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0, 1),
                     (self.digital_header_payload_demux_0, 1))
        self.connect((self.digital_packet_headergenerator_bb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.fft_vxx_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0, 0))
        self.connect((self.fft_vxx_0_0, 0),
                     (self.digital_ofdm_cyclic_prefixer_0, 0))
        self.connect((self.fft_vxx_1, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_time_sink_x_1, 0))
Exemplo n.º 40
0
    def __init__(self, cw_len=64, payload_len=255, samp_rate=1e6):
        gr.hier_block2.__init__(
            self,
            "Wes Packet Tx",
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signaturev(6, 6, [
                gr.sizeof_gr_complex * 1, gr.sizeof_char * 1, gr.sizeof_char *
                1, gr.sizeof_char * 1, gr.sizeof_char * 1, gr.sizeof_char * 1
            ]),
        )

        ##################################################
        # Parameters
        ##################################################
        self.cw_len = cw_len
        self.payload_len = payload_len
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.num_tag_key = num_tag_key = "packet_num"
        self.len_tag_key = len_tag_key = "packet_length"
        self.header_len = header_len = 32
        self.throttle_rate = throttle_rate = 100e3
        self.tag_s = tag_s = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(payload_len),
             pmt.intern("vect_test_src")))
        self.tag0 = tag0 = gr.tag_utils.python_to_tag(
            (0, pmt.intern(len_tag_key), pmt.from_long(cw_len),
             pmt.intern("vect_cw_src")))
        self.sync_seq = sync_seq = [
            1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1,
            -1, 1, 1, -1, -1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1,
            -1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1,
            -1, -1, 1, 1, 1, 1, 1, 1
        ]
        self.sync_len = sync_len = 63
        self.sym_table = sym_table = [-1, 1]
        self.pi = pi = 3.141592654
        self.header_formatter = header_formatter = digital.packet_header_default(
            header_len, len_tag_key, num_tag_key, 1)
        self.diff_mod = diff_mod = 4
        self.cw = cw = int((cw_len / 4)) * [1, 0, 1, 0]
        self.const = const = digital.constellation_calcdist(
            digital.psk_4()[0],
            digital.psk_4()[1], 2, 1).base()

        ##################################################
        # Blocks
        ##################################################
        self.digital_packet_headergenerator_bb_0_0 = digital.packet_headergenerator_bb(
            header_formatter.formatter(), len_tag_key)
        self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1)
        self.digital_diff_encoder_bb_0_0 = digital.diff_encoder_bb(2)
        self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2)
        self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(
            (-1, 1), 1)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b(
            cw, True, 1, [tag0])
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, len_tag_key, 0)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_stream_to_tagged_stream_1 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, sync_len, "packet_length")
        self.blocks_stream_to_tagged_stream_0_0_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, payload_len, len_tag_key)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, header_len, len_tag_key)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(
            1, 1, "packet_length", False, gr.GR_LSB_FIRST)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.digital_diff_encoder_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self, 5))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.digital_diff_encoder_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0_0_0, 0),
                     (self.digital_packet_headergenerator_bb_0_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_stream_to_tagged_stream_1, 0), (self, 2))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.blocks_vector_source_x_0_0, 0), (self, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self, 0))
        self.connect((self.digital_diff_encoder_bb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 2))
        self.connect((self.digital_diff_encoder_bb_0, 0), (self, 4))
        self.connect((self.digital_diff_encoder_bb_0_0, 0),
                     (self.blocks_tagged_stream_mux_0, 3))
        self.connect((self.digital_diff_encoder_bb_0_0, 0), (self, 3))
        self.connect((self.digital_glfsr_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_1, 0))
        self.connect((self.digital_packet_headergenerator_bb_0_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self, 0), (self.blocks_stream_to_tagged_stream_0_0_0, 0))
Exemplo n.º 41
0
    def __init__(self,
                 header_format=digital.header_format_default(
                     digital.packet_utils.default_access_code, 0),
                 length_tag_name='packet_len'):
        gr.top_block.__init__(self, "Fsk Msg")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Fsk Msg")
        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", "fsk_msg")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.header_format = header_format
        self.length_tag_name = length_tag_name

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, '', '',
                                                       False, False, '')
        self._qtgui_edit_box_msg_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win)
        self.epy_block_0 = epy_block_0.msg_block()
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            header_format, length_tag_name)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_char * 1, length_tag_name, 0)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.epy_block_0, 'msg_out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'),
                         (self.epy_block_0, 'msg_in'))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
Exemplo n.º 42
0
    def __init__(self):
        gr.top_block.__init__(self, "SECUNDARY")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("SECUNDARY")
        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", "secundary")

        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_gain = tx_gain = 50
        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.rx_gain = rx_gain = 50
        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.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._tx_gain_tool_bar = Qt.QToolBar(self)
        self._tx_gain_tool_bar.addWidget(Qt.QLabel('tx_gain' + ": "))
        self._tx_gain_line_edit = Qt.QLineEdit(str(self.tx_gain))
        self._tx_gain_tool_bar.addWidget(self._tx_gain_line_edit)
        self._tx_gain_line_edit.returnPressed.connect(lambda: self.set_tx_gain(
            eng_notation.str_to_num(str(self._tx_gain_line_edit.text()))))
        self.top_layout.addWidget(self._tx_gain_tool_bar)
        self._rx_gain_tool_bar = Qt.QToolBar(self)
        self._rx_gain_tool_bar.addWidget(Qt.QLabel('rx_gain' + ": "))
        self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain))
        self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit)
        self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain(
            eng_notation.str_to_num(str(self._rx_gain_line_edit.text()))))
        self.top_layout.addWidget(self._rx_gain_tool_bar)
        self.uhd_usrp_source_0_0_1 = uhd.usrp_source(
            ",".join(('serial=F5C243', "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0_0_1.set_center_freq(2400000000, 0)
        self.uhd_usrp_source_0_0_1.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0_0_1.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_0_1.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0_1.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
            ",".join(('serial=F5C234', "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0_0.set_center_freq(2450000000, 0)
        self.uhd_usrp_source_0_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(('serial=F5C234', "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            length_tag_key,
        )
        self.uhd_usrp_sink_0_0.set_center_freq(2400000000, 0)
        self.uhd_usrp_sink_0_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('serial=F5C243', "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
            length_tag_key,
        )
        self.uhd_usrp_sink_0.set_center_freq(2450000000, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX/RX', 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_unknown_pps(uhd.time_spec())
        self.qtgui_sink_x_0_0 = qtgui.sink_c(
            64,  #fftsize
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            4000000000,  #fc
            50000,  #bw
            'SECUNDARY RX',  #name
            True,  #plotfreq
            True,  #plotwaterfall
            True,  #plottime
            True  #plotconst
        )
        self.qtgui_sink_x_0_0.set_update_time(1.0 / 10)
        self._qtgui_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_sink_x_0_0.pyqwidget(), Qt.QWidget)

        self.qtgui_sink_x_0_0.enable_rf_freq(False)

        self.top_layout.addWidget(self._qtgui_sink_x_0_0_win)
        self.fft_vxx_1_0_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_1_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0_0_0_0_0_0 = fft.fft_vcc(fft_len, True, (), True, 1)
        self.fft_vxx_0_0_0_0_0_0 = 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, False, (), True, 1)
        self.epy_block_0_0 = epy_block_0_0.mac()
        self.epy_block_0 = epy_block_0.mac()
        self.digital_protocol_formatter_bb_0_0 = digital.protocol_formatter_bb(
            hdr_format, length_tag_key)
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(
            hdr_format, length_tag_key)
        self.digital_packet_headerparser_b_0_0_0_0_0_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_packet_headerparser_b_0_0_0_0_0 = digital.packet_headerparser_b(
            header_formatter.base())
        self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.9)
        self.digital_ofdm_sync_sc_cfb_0_0_0_0_0 = digital.ofdm_sync_sc_cfb(
            fft_len, fft_len // 4, False, 0.9)
        self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_payload_0_0_0_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, packet_length_tag_key,
            1, '', True)
        self.digital_ofdm_serializer_vcc_header_0_0_0_0_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, '', 0, '', True)
        self.digital_ofdm_serializer_vcc_header_0_0_0_0 = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, length_tag_key, '', 0, '', True)
        self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), fft_len // 4, length_tag_key, True, 0)
        self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key, True, 1)
        self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0 = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(), fft_len // 4, length_tag_key, True, 1)
        self.digital_ofdm_cyclic_prefixer_0_0 = digital.ofdm_cyclic_prefixer(
            fft_len, fft_len + fft_len // 4, rolloff, 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_chanest_vcvc_0_0_0_0_0_0 = digital.ofdm_chanest_vcvc(
            sync_word1, sync_word2, 1, 0, 3, False)
        self.digital_ofdm_chanest_vcvc_0_0_0_0_0 = digital.ofdm_chanest_vcvc(
            sync_word1, sync_word2, 1, 0, 3, False)
        self.digital_ofdm_carrier_allocator_cvc_0_0 = digital.ofdm_carrier_allocator_cvc(
            fft_len, occupied_carriers, pilot_carriers, pilot_symbols,
            (sync_word1, sync_word2), length_tag_key, True)
        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_0_0_0_0_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_header_payload_demux_0_0_0_0_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_constellation_decoder_cb_1_0_0_0_0_0 = digital.constellation_decoder_cb(
            payload_mod.base())
        self.digital_constellation_decoder_cb_1_0_0_0_0 = digital.constellation_decoder_cb(
            payload_mod.base())
        self.digital_constellation_decoder_cb_0_0_0_0_0_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_constellation_decoder_cb_0_0_0_0_0 = digital.constellation_decoder_cb(
            header_mod.base())
        self.digital_chunks_to_symbols_xx_0_1 = digital.chunks_to_symbols_bc(
            header_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0_0_0 = digital.chunks_to_symbols_bc(
            payload_mod.points(), 1)
        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_to_pdu_0_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, length_tag_key)
        self.blocks_tagged_stream_to_pdu_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, length_tag_key)
        self.blocks_tagged_stream_mux_0_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(
            gr.sizeof_gr_complex * 1, length_tag_key, 0)
        self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                   True)
        self.blocks_tag_gate_0_0.set_single_key("")
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1,
                                                 True)
        self.blocks_tag_gate_0.set_single_key("")
        self.blocks_repack_bits_bb_0_2_0 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_2 = blocks.repack_bits_bb(
            8, payload_mod.bits_per_symbol(), length_tag_key, False,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_1_0_0_0_0_0 = blocks.repack_bits_bb(
            payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_1_0_0_0_0 = blocks.repack_bits_bb(
            payload_mod.bits_per_symbol(), 8, packet_length_tag_key, True,
            gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0_1_0 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0_0_1 = blocks.repack_bits_bb(
            8, 1, length_tag_key, False, gr.GR_LSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, length_tag_key)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, length_tag_key)
        self.blocks_multiply_xx_0_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_0_0_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_cc(50e-3)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_cc(50e-3)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_delay_0_0_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                                     fft_len + fft_len // 4)
        self.blocks_delay_0_0_0_0_0 = blocks.delay(gr.sizeof_gr_complex * 1,
                                                   fft_len + fft_len // 4)
        self.analog_frequency_modulator_fc_0_0_0_0_0_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)
        self.analog_frequency_modulator_fc_0_0_0_0_0 = analog.frequency_modulator_fc(
            -2.0 / fft_len)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.epy_block_0_0, 'time_unit'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self.epy_block_0_0, 'ack'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0, 'pdus'),
                         (self.epy_block_0, 'packet'))
        self.msg_connect(
            (self.digital_packet_headerparser_b_0_0_0_0_0, 'header_data'),
            (self.digital_header_payload_demux_0_0_0_0_0, 'header_data'))
        self.msg_connect(
            (self.digital_packet_headerparser_b_0_0_0_0_0_0, 'header_data'),
            (self.digital_header_payload_demux_0_0_0_0_0_0, 'header_data'))
        self.msg_connect((self.epy_block_0, 'ack'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.epy_block_0_0, 'transmit_packet'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.epy_block_0_0, 'channel_up'),
                         (self.uhd_usrp_sink_0_0, 'command'))
        self.msg_connect((self.epy_block_0_0, 'channel_down'),
                         (self.uhd_usrp_source_0_0, 'command'))
        self.connect((self.analog_frequency_modulator_fc_0_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 0))
        self.connect((self.analog_frequency_modulator_fc_0_0_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 0))
        self.connect((self.blocks_delay_0_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0, 1))
        self.connect((self.blocks_delay_0_0_0_0_0_0, 0),
                     (self.blocks_multiply_xx_0_0_0_0_0_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0),
                     (self.blocks_tag_gate_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0, 0),
                     (self.digital_header_payload_demux_0_0_0_0_0, 0))
        self.connect((self.blocks_multiply_xx_0_0_0_0_0_0, 0),
                     (self.digital_header_payload_demux_0_0_0_0_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.blocks_repack_bits_bb_0_2, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_protocol_formatter_bb_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.blocks_repack_bits_bb_0_2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.digital_protocol_formatter_bb_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_1, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_1_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_1, 0))
        self.connect((self.blocks_repack_bits_bb_0_1_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_1_0_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_2, 0),
                     (self.digital_chunks_to_symbols_xx_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_2_0, 0),
                     (self.digital_chunks_to_symbols_xx_0_0_0, 0))
        self.connect((self.blocks_tag_gate_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_tag_gate_0_0, 0),
                     (self.uhd_usrp_sink_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, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_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_chunks_to_symbols_xx_0_0_0, 0),
                     (self.blocks_tagged_stream_mux_0_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_1, 0),
                     (self.blocks_tagged_stream_mux_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0, 0),
                     (self.digital_packet_headerparser_b_0_0_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0_0_0_0_0, 0),
                     (self.digital_packet_headerparser_b_0_0_0_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1_0_0_0_0, 0),
                     (self.blocks_repack_bits_bb_0_1_0_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_1_0_0_0_0_0, 0),
                     (self.blocks_repack_bits_bb_0_1_0_0_0_0_0, 0))
        self.connect((self.digital_header_payload_demux_0_0_0_0_0, 0),
                     (self.fft_vxx_0_0_0_0_0_0, 0))
        self.connect((self.digital_header_payload_demux_0_0_0_0_0, 1),
                     (self.fft_vxx_1_0_0_0_0, 0))
        self.connect((self.digital_header_payload_demux_0_0_0_0_0_0, 0),
                     (self.fft_vxx_0_0_0_0_0_0_0, 0))
        self.connect((self.digital_header_payload_demux_0_0_0_0_0_0, 1),
                     (self.fft_vxx_1_0_0_0_0_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, 0),
                     (self.fft_vxx_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0_0_0_0_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_chanest_vcvc_0_0_0_0_0_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.digital_ofdm_cyclic_prefixer_0_0, 0),
                     (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0, 0),
                     (self.digital_ofdm_serializer_vcc_header_0_0_0_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_0_0_0_0_0_0, 0),
                     (self.digital_ofdm_serializer_vcc_header_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0, 0),
                     (self.digital_ofdm_serializer_vcc_payload_0_0_0_0, 0))
        self.connect((self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0, 0),
                     (self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header_0_0_0_0, 0),
                     (self.digital_constellation_decoder_cb_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_header_0_0_0_0_0, 0),
                     (self.digital_constellation_decoder_cb_0_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload_0_0_0_0, 0),
                     (self.digital_constellation_decoder_cb_1_0_0_0_0, 0))
        self.connect((self.digital_ofdm_serializer_vcc_payload_0_0_0_0_0, 0),
                     (self.digital_constellation_decoder_cb_1_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 0),
                     (self.analog_frequency_modulator_fc_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 1),
                     (self.digital_header_payload_demux_0_0_0_0_0, 1))
        self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 0),
                     (self.analog_frequency_modulator_fc_0_0_0_0_0_0, 0))
        self.connect((self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 1),
                     (self.digital_header_payload_demux_0_0_0_0_0_0, 1))
        self.connect((self.digital_protocol_formatter_bb_0, 0),
                     (self.blocks_repack_bits_bb_0_0_1, 0))
        self.connect((self.digital_protocol_formatter_bb_0_0, 0),
                     (self.blocks_repack_bits_bb_0_0_1_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_cyclic_prefixer_0_0, 0))
        self.connect((self.fft_vxx_0_0_0_0_0_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_0_0_0_0_0_0_0, 0),
                     (self.digital_ofdm_chanest_vcvc_0_0_0_0_0_0, 0))
        self.connect((self.fft_vxx_1_0_0_0_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0, 0))
        self.connect((self.fft_vxx_1_0_0_0_0_0, 0),
                     (self.digital_ofdm_frame_equalizer_vcvc_1_0_0_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.blocks_delay_0_0_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0),
                     (self.digital_ofdm_sync_sc_cfb_0_0_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0, 0), (self.qtgui_sink_x_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0_1, 0),
                     (self.blocks_delay_0_0_0_0_0_0, 0))
        self.connect((self.uhd_usrp_source_0_0_1, 0),
                     (self.digital_ofdm_sync_sc_cfb_0_0_0_0_0_0, 0))
Exemplo n.º 43
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))
Exemplo n.º 44
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", "ofdm_tx_virtualsource_qt")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # 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 = 96
        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.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.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_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_rx_0 = digital.ofdm_rx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            frame_length_tag_key='frame_' + "length",
            packet_length_tag_key="length",
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            debug_log=False,
            scramble_bits=False)
        self.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.channels_channel_model_0 = channels.channel_model(
            noise_voltage=0.0,
            frequency_offset=0.0,
            epsilon=1.0,
            taps=(1.0 + 1.0j, ),
            noise_seed=0,
            block_tags=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_0 = blocks.tag_debug(gr.sizeof_char * 1,
                                                   "Rx'd Packets", "")
        self.blocks_tag_debug_0.set_display(True)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, packet_len, 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.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_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.blocks_throttle_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.digital_ofdm_carrier_allocator_cvc_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.qtgui_const_sink_x_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.channels_channel_model_0, 0),
                     (self.digital_ofdm_rx_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_ofdm_rx_0, 0), (self.blocks_tag_debug_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, "Frame Sync")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Frame Sync")
        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", "frame_sync")

        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.samp_rate = samp_rate = 32000
        self.length_tag_key = length_tag_key = "# of bits"
        self.header_mod = header_mod = digital.constellation_bpsk()

        ##################################################
        # Blocks
        ##################################################
        self.digital_protocol_formatter_bb_0 = digital.protocol_formatter_bb(hdr_format, length_tag_key)
        self.digital_crc32_bb_0_0 = digital.crc32_bb(True, length_tag_key, True)
        self.digital_crc32_bb_0 = digital.crc32_bb(False, length_tag_key, True)
        self.digital_correlate_access_code_xx_ts_1 = digital.correlate_access_code_bb_ts(digital.packet_utils.default_access_code,
          1, length_tag_key)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(header_mod.base())
        self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1)
        self.digital_chunks_to_symbols_xx_0_0_0_0_0 = digital.chunks_to_symbols_bc(header_mod.points(), 1)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, length_tag_key)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, length_tag_key, 0)
        self.blocks_tag_gate_0_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False)
        self.blocks_tag_gate_0_0.set_single_key("")
        self.blocks_repack_bits_bb_0_0_1_0 = blocks.repack_bits_bb(8, header_mod.bits_per_symbol(), length_tag_key, False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0_1 = blocks.repack_bits_bb(8, header_mod.bits_per_symbol(), length_tag_key, False, gr.GR_MSB_FIRST)
        self.blocks_repack_bits_bb_0_0_0 = blocks.repack_bits_bb(1, 8, length_tag_key, False, gr.GR_MSB_FIRST)
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, length_tag_key)
        self.blocks_message_strobe_0_0_0_0 = blocks.message_strobe(pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(numpy.array([ord(c) for c in "Beyond 5G"], numpy.uint8))), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 0.7, 0)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0_0_0, 'strobe'), (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_tag_gate_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.digital_crc32_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_0, 0), (self.digital_crc32_bb_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_1, 0), (self.digital_chunks_to_symbols_xx_0_0_0_0_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0_1_0, 0), (self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0, 0))
        self.connect((self.blocks_tag_gate_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0_0_0_0_0, 0), (self.blocks_tagged_stream_mux_0, 1))
        self.connect((self.digital_chunks_to_symbols_xx_0_0_0_0_0_0_0_0, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_correlate_access_code_xx_ts_1, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_1, 0), (self.blocks_repack_bits_bb_0_0_0, 0))
        self.connect((self.digital_crc32_bb_0, 0), (self.blocks_repack_bits_bb_0_0_1, 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_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_protocol_formatter_bb_0, 0), (self.blocks_repack_bits_bb_0_0_1_0, 0))
Exemplo n.º 46
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Transmitter")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1000000

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr==192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(1000000, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.digital_packet_headergenerator_bb_0 = digital.packet_headergenerator_bb(digital.packet_header_default(40,"packet_len"), "packet_len")
        self.digital_gmsk_mod_0 = digital.gmsk_mod(
        	samples_per_symbol=2,
        	bt=0.35,
        	verbose=False,
        	log=False,
        )
        self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len", True)
        self.digital_chunks_to_symbols_xx_1_0 = digital.chunks_to_symbols_bc((digital.constellation_bpsk().points()), 1)
        self.digital_chunks_to_symbols_xx_1 = digital.chunks_to_symbols_bc((digital.constellation_bpsk().points()), 1)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tun0', 10000, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_tagged_stream_mux_0 = blocks.tagged_stream_mux(gr.sizeof_gr_complex*1, "packet_len", 0)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "packet_len", False, gr.GR_LSB_FIRST)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blks2_packet_encoder_0 = grc_blks2.packet_mod_c(grc_blks2.packet_encoder(
        		samples_per_symbol=2,
        		bits_per_symbol=1,
        		preamble='',
        		access_code='',
        		pad_for_usrp=False,
        	),
        	payload_length=0,
        )



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_chunks_to_symbols_xx_1_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_packet_headergenerator_bb_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0), (self.blks2_packet_encoder_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.digital_crc32_bb_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1, 0), (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_1_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_gmsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.digital_packet_headergenerator_bb_0, 0), (self.digital_chunks_to_symbols_xx_1, 0))