Exemplo n.º 1
0
 def test_additive_scrambler_tags(self):
     src_data = (1, ) * 1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     reset_tag_key = 'reset_lfsr'
     reset_tag1 = gr.tag_t()
     reset_tag1.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag1.offset = 17
     reset_tag2 = gr.tag_t()
     reset_tag2.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag2.offset = 110
     reset_tag3 = gr.tag_t()
     reset_tag3.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag3.offset = 523
     src = blocks.vector_source_b(src_data, False, 1,
                                  (reset_tag1, reset_tag2, reset_tag3))
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 1,
                                               reset_tag_key)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 1,
                                                 reset_tag_key)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(src_data, dst.data())
Exemplo n.º 2
0
 def test_additive_scrambler_reset(self):
     src_data = (1,)*1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(src_data, dst.data())
Exemplo n.º 3
0
 def test_additive_scrambler_reset(self):
     src_data = (1,)*1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(src_data, dst.data())
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, "lilacsat_1_deframer",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')
        self.message_port_register_hier_out('codec2')

        if syncword_threshold is None:
            syncword_threshold = self.options.syncword_threshold

        self.delay1 = blocks.delay(gr.sizeof_float, 1)
        self.viterbi0 = ccsds_viterbi()
        self.viterbi1 = ccsds_viterbi()
        self.differential0 = digital.diff_decoder_bb(2)
        self.differential1 = digital.diff_decoder_bb(2)
        self.tag0 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.tag1 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.scrambler0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.scrambler1 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.demux0 = lilacsat1_demux('syncword')
        self.demux1 = lilacsat1_demux('syncword')
        self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.multiply_length = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, 'packet_len', 1 / 8.0)
        self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.pdu2tag_codec2 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.pack_codec2 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.multiply_length_codec2 = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, 'packet_len', 1 / 8.0)
        self.tag2pdu_codec2 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')

        self.connect(self, self.viterbi0, self.differential0, self.tag0,
                     self.scrambler0, self.demux0)
        self.connect(self, self.delay1, self.viterbi1, self.differential1,
                     self.tag1, self.scrambler1, self.demux1)
        self.connect(self.pdu2tag, self.pack, self.multiply_length,
                     self.tag2pdu)
        self.connect(self.pdu2tag_codec2, self.pack_codec2,
                     self.multiply_length_codec2, self.tag2pdu_codec2)
        self.msg_connect((self.demux0, 'kiss'), (self.pdu2tag, 'pdus'))
        self.msg_connect((self.demux1, 'kiss'), (self.pdu2tag, 'pdus'))
        self.msg_connect((self.demux0, 'codec2'),
                         (self.pdu2tag_codec2, 'pdus'))
        self.msg_connect((self.demux1, 'codec2'),
                         (self.pdu2tag_codec2, 'pdus'))
        self.msg_connect((self.tag2pdu, 'pdus'), (self, 'out'))
        self.msg_connect((self.tag2pdu_codec2, 'pdus'), (self, 'codec2'))
Exemplo n.º 5
0
 def test_additive_scrambler_001(self):
     _a = lfsr_args(1, 51, 3, 0)  # i p(x) = x^51+x^3+1, seed 0x1
     src_data = np.random.randint(0, 2, 1000, dtype=np.int8).tolist()
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(*_a)
     descrambler = digital.additive_scrambler_bb(*_a)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(tuple(src_data), tuple(dst.data()))
Exemplo n.º 6
0
 def test_additive_scrambler_reset_3bpb(self):
     src_data = (5,)*2000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 3)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 3)
     dst = blocks.vector_sink_b()
     dst2 = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.connect(scrambler, dst2)
     self.tb.run()
     if not (src_data == dst.data()):
         self.fail('Not equal.')
     self.assertEqual(src_data, src_data)
Exemplo n.º 7
0
 def test_additive_scrambler_reset_3bpb(self):
     src_data = (5,)*2000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 3)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 3)
     dst = blocks.vector_sink_b()
     dst2 = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.connect(scrambler, dst2)
     self.tb.run()
     if not (src_data == dst.data()):
         self.fail('Not equal.')
     self.assertEqual(src_data, src_data)
Exemplo n.º 8
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            'PN9 scrambler',
            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')

        ##################################################
        # Blocks
        ##################################################
        self.digital_additive_scrambler_bb_0 = (
            digital.additive_scrambler_bb(0x21, 0x1FF, 8, count=0,
                                          bits_per_byte=8,
                                          reset_tag_key='packet_len'))
        self.blocks_tagged_stream_to_pdu_0 = (
            blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len'))
        self.blocks_pdu_to_tagged_stream_0 = (
            blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len'))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self, 'out'))
        self.msg_connect(
            (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect(
            (self.blocks_pdu_to_tagged_stream_0, 0),
            (self.digital_additive_scrambler_bb_0, 0))
        self.connect(
            (self.digital_additive_scrambler_bb_0, 0),
            (self.blocks_tagged_stream_to_pdu_0, 0))
Exemplo n.º 9
0
 def test_additive_scrambler_reset_3bpb(self):
     src_data = (5, ) * 200
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 50, 3)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, dst)
     self.tb.run()
     output = dst.data()
     self.assertEqual(output[:50] * 4, output)
Exemplo n.º 10
0
 def test_additive_scrambler_tags(self):
     src_data = (1,)*1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100)
     reset_tag_key = 'reset_lfsr'
     reset_tag1 = gr.tag_t()
     reset_tag1.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag1.offset = 17
     reset_tag2 = gr.tag_t()
     reset_tag2.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag2.offset = 110
     reset_tag3 = gr.tag_t()
     reset_tag3.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag3.offset = 523
     src = blocks.vector_source_b(src_data, False, 1, (reset_tag1, reset_tag2, reset_tag3))
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 1, reset_tag_key)
     descrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 100, 1, reset_tag_key)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, descrambler, dst)
     self.tb.run()
     self.assertEqual(src_data, dst.data())
Exemplo n.º 11
0
 def test_additive_scrambler_002(self):
     _a = lfsr_args(1, 51, 3, 0)  # i p(x) = x^51+x^3+1, seed 0x1
     src_data = [
         1,
     ] * 1000
     src = blocks.vector_source_b(src_data, False)
     scrambler = digital.additive_scrambler_bb(*_a)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, dst)
     self.tb.run()
     reg = np.zeros(52, np.int8)
     reg[::-1][(51, 3, 0), ] = 1
     res = (np.convolve(dst.data(), reg) % 2)[52:-52]
     self.assertEqual(len(res), sum(res))  # when convolved with mask,
Exemplo n.º 12
0
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, 'lilacsat_1_deframer',
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')
        self.message_port_register_hier_out('codec2')

        if syncword_threshold is None:
            syncword_threshold = self.options.syncword_threshold

        self.delay1 = blocks.delay(gr.sizeof_float, 1)
        self.viterbi0 = ccsds_viterbi()
        self.viterbi1 = ccsds_viterbi()
        self.differential0 = digital.diff_decoder_bb(2)
        self.differential1 = digital.diff_decoder_bb(2)
        self.tag0 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.tag1 = digital.correlate_access_code_tag_bb(
            _syncword, syncword_threshold, 'syncword')
        self.scrambler0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.scrambler1 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword')
        self.demux0 = lilacsat1_demux('syncword')
        self.demux1 = lilacsat1_demux('syncword')

        self.connect(self, self.viterbi0, self.differential0, self.tag0,
                     self.scrambler0, self.demux0)
        self.connect(self, self.delay1, self.viterbi1, self.differential1,
                     self.tag1, self.scrambler1, self.demux1)
        self.msg_connect((self.demux0, 'frame'), (self, 'out'))
        self.msg_connect((self.demux1, 'frame'), (self, 'out'))
        self.msg_connect((self.demux0, 'codec2'), (self, 'codec2'))
        self.msg_connect((self.demux1, 'codec2'), (self, 'codec2'))
Exemplo n.º 13
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            'CCSDS descrambler',
            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")

        ##################################################
        # Blocks
        ##################################################
        self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1,
            reset_tag_key="packet_len")
        self.blocks_unpacked_to_packed_xx_0_0_0_0 = (
            blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST))
        self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = (
            blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len'))
        self.blocks_tagged_stream_multiply_length_0_0_0_0 = (
            blocks.tagged_stream_multiply_length(
                gr.sizeof_char*1, 'packet_len', 1/8.0))
        self.blocks_pdu_to_tagged_stream_0 = (
            blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len'))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
            (self, 'out'))
        self.msg_connect(
            (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect(
            (self.blocks_pdu_to_tagged_stream_0, 0),
            (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect(
            (self.blocks_tagged_stream_multiply_length_0_0_0_0, 0),
            (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect(
            (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
            (self.blocks_tagged_stream_multiply_length_0_0_0_0, 0))
        self.connect(
            (self.digital_additive_scrambler_bb_0_0, 0),
            (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
Exemplo n.º 14
0
    def __init__(self):
        gr.hier_block2.__init__(
            self,
            'SI4463 scrambler',
            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')

        ##################################################
        # Blocks
        ##################################################
        self.digital_additive_scrambler_bb_0_0 = (
            digital.additive_scrambler_bb(
                0x21, 0x1e1, 8, count=0, bits_per_byte=1,
                reset_tag_key="packet_len"))
        self.blocks_tagged_stream_to_pdu_0_0 = (
            blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len'))
        self.blocks_tagged_stream_multiply_length_0 = (
            blocks.tagged_stream_multiply_length(gr.sizeof_char*1,
                                                 'packet_len', 1.0/8))
        self.blocks_pdu_to_tagged_stream_0 = (
            blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len'))
        self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect(
            (self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self, 'out'))
        self.msg_connect(
            (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect(
            (self.blocks_pack_k_bits_bb_0, 0),
            (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect(
            (self.blocks_pdu_to_tagged_stream_0, 0),
            (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect(
            (self.blocks_tagged_stream_multiply_length_0, 0),
            (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect(
            (self.digital_additive_scrambler_bb_0_0, 0),
            (self.blocks_pack_k_bits_bb_0, 0))
Exemplo n.º 15
0
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, 'grizu263a_deframer',
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')

        if syncword_threshold is None:
            syncword_threshold = self.options.syncword_threshold

        self.slicer = digital.binary_slicer_fb()
        self.sync = sync_to_pdu_packed(packlen=255,
                                       sync=_syncword,
                                       threshold=syncword_threshold)
        self.reflect_1 = reflect_bytes()

        # The scrambler is like the PN9, but uses 0x100 instead of 0x1FF
        # as seed.
        self.scrambler = digital.additive_scrambler_bb(
            0x21,
            0x100,
            8,
            count=0,
            bits_per_byte=8,
            reset_tag_key='packet_len')
        self.stream2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t,
                                                      'packet_len')
        self.pdu2stream = blocks.pdu_to_tagged_stream(blocks.byte_t,
                                                      'packet_len')

        self.reflect_2 = reflect_bytes()
        self.crop = sx12xx_packet_crop(crc_len=2)
        self.crc = check_cc11xx_crc(self.options.verbose_crc)
        self.remove_length = pdu_head_tail(3, 1)

        self.connect(self, self.slicer, self.sync)
        self.msg_connect((self.sync, 'out'), (self.reflect_1, 'in'))
        self.msg_connect((self.reflect_1, 'out'), (self.pdu2stream, 'pdus'))
        self.connect(self.pdu2stream, self.scrambler, self.stream2pdu)
        self.msg_connect((self.stream2pdu, 'pdus'), (self.reflect_2, 'in'))
        self.msg_connect((self.reflect_2, 'out'), (self.crop, 'in'))
        self.msg_connect((self.crop, 'out'), (self.crc, 'in'))
        self.msg_connect((self.crc, 'ok'), (self.remove_length, 'in'))
        self.msg_connect((self.remove_length, 'out'), (self, 'out'))
Exemplo n.º 16
0
 def test_additive_scrambler_tags_oneway(self):
     src_data = range(0, 10)
     reset_tag_key = 'reset_lfsr'
     reset_tag1 = gr.tag_t()
     reset_tag1.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag1.offset = 0
     reset_tag2 = gr.tag_t()
     reset_tag2.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag2.offset = 10
     reset_tag3 = gr.tag_t()
     reset_tag3.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag3.offset = 20
     src = blocks.vector_source_b(src_data * 3, False, 1, (reset_tag1, reset_tag2, reset_tag3))
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 0, 8, reset_tag_key)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, dst)
     self.tb.run()
     expected_data = additive_scramble_lfsr(0x8a, 0x7f, 7, 8, src_data)
     self.assertEqual(expected_data * 3, dst.data())
Exemplo n.º 17
0
 def test_additive_scrambler_tags_oneway(self):
     src_data = [x for x in range(0, 10)]
     reset_tag_key = 'reset_lfsr'
     reset_tag1 = gr.tag_t()
     reset_tag1.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag1.offset = 0
     reset_tag2 = gr.tag_t()
     reset_tag2.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag2.offset = 10
     reset_tag3 = gr.tag_t()
     reset_tag3.key = pmt.string_to_symbol(reset_tag_key)
     reset_tag3.offset = 20
     src = blocks.vector_source_b(src_data * 3, False, 1, (reset_tag1, reset_tag2, reset_tag3))
     scrambler = digital.additive_scrambler_bb(0x8a, 0x7f, 7, 0, 8, reset_tag_key)
     dst = blocks.vector_sink_b()
     self.tb.connect(src, scrambler, dst)
     self.tb.run()
     expected_data = additive_scramble_lfsr(0x8a, 0x7f, 7, 8, src_data)
     self.assertEqual(expected_data * 3, dst.data())
Exemplo n.º 18
0
    def __init__(self, options=None):
        gr.hier_block2.__init__(self, "ops_sat_deframer",
                                gr.io_signature(1, 1, gr.sizeof_float),
                                gr.io_signature(0, 0, 0))
        options_block.__init__(self, options)

        self.message_port_register_hier_out('out')

        self.slicer = digital.binary_slicer_fb()
        self.nrzi = nrzi_decode()
        self.descrambler = digital.descrambler_bb(0x21, 0, 16)
        self.deframer = hdlc_deframer(False, 10000)  # we skip CRC-16 check
        self.strip = pdu_head_tail(3, 16)

        # CCSDS descrambler
        self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.scramble = digital.additive_scrambler_bb(
            0xA9,
            0xFF,
            7,
            count=0,
            bits_per_byte=1,
            reset_tag_key="packet_len")
        self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')

        # prevents passing codewords of incorrect size to the RS decoder
        self.length_filter = pdu_length_filter(33, 255)
        self.fec = decode_rs(False, 1)

        self.connect(self, self.slicer, self.nrzi, self.descrambler,
                     self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.strip, 'in'))
        self.msg_connect((self.strip, 'out'), (self.pdu2tag, 'pdus'))
        self.connect(self.pdu2tag, self.unpack, self.scramble, self.pack,
                     self.tag2pdu)
        self.msg_connect((self.tag2pdu, 'pdus'), (self.length_filter, 'in'))
        self.msg_connect((self.length_filter, 'out'), (self.fec, 'in'))
        self.msg_connect((self.fec, 'out'), (self, 'out'))
Exemplo n.º 19
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",
        )
Exemplo n.º 20
0
 def __init__(self,
              fft_len=_def_fft_len,
              cp_len=_def_cp_len,
              packet_length_tag_key=_def_packet_length_tag_key,
              occupied_carriers=_def_occupied_carriers,
              pilot_carriers=_def_pilot_carriers,
              pilot_symbols=_def_pilot_symbols,
              bps_header=1,
              bps_payload=1,
              sync_word1=None,
              sync_word2=None,
              rolloff=0,
              debug_log=False,
              scramble_bits=False):
     gr.hier_block2.__init__(self, "ofdm_tx",
                             gr.io_signature(1, 1, gr.sizeof_char),
                             gr.io_signature(1, 1, gr.sizeof_gr_complex))
     ### Param init / sanity check ########################################
     self.fft_len = fft_len
     self.cp_len = cp_len
     self.packet_length_tag_key = packet_length_tag_key
     self.occupied_carriers = occupied_carriers
     self.pilot_carriers = pilot_carriers
     self.pilot_symbols = pilot_symbols
     self.bps_header = bps_header
     self.bps_payload = bps_payload
     self.sync_word1 = sync_word1
     if sync_word1 is None:
         self.sync_word1 = _make_sync_word1(fft_len, occupied_carriers,
                                            pilot_carriers)
     else:
         if len(sync_word1) != self.fft_len:
             raise ValueError(
                 "Length of sync sequence(s) must be FFT length.")
     self.sync_words = [
         self.sync_word1,
     ]
     if sync_word2 is None:
         self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers,
                                            pilot_carriers)
     else:
         self.sync_word2 = sync_word2
     if len(self.sync_word2):
         if len(self.sync_word2) != fft_len:
             raise ValueError(
                 "Length of sync sequence(s) must be FFT length.")
         self.sync_word2 = list(self.sync_word2)
         self.sync_words.append(self.sync_word2)
     if scramble_bits:
         self.scramble_seed = 0x7f
     else:
         self.scramble_seed = 0x00  # We deactivate the scrambler by init'ing it with zeros
     ### Header modulation ################################################
     crc = digital.crc32_bb(False, self.packet_length_tag_key)
     header_constellation = _get_constellation(bps_header)
     header_mod = digital.chunks_to_symbols_bc(
         header_constellation.points())
     formatter_object = digital.packet_header_ofdm(
         occupied_carriers=occupied_carriers,
         n_syms=1,
         bits_per_header_sym=self.bps_header,
         bits_per_payload_sym=self.bps_payload,
         scramble_header=scramble_bits)
     header_gen = digital.packet_headergenerator_bb(
         formatter_object.base(), self.packet_length_tag_key)
     header_payload_mux = blocks.tagged_stream_mux(
         itemsize=gr.sizeof_gr_complex * 1,
         lengthtagname=self.packet_length_tag_key,
         tag_preserve_head_pos=
         1  # Head tags on the payload stream stay on the head
     )
     self.connect(self, crc, header_gen, header_mod,
                  (header_payload_mux, 0))
     if debug_log:
         self.connect(header_gen, blocks.file_sink(1, 'tx-hdr.dat'))
     ### Payload modulation ###############################################
     payload_constellation = _get_constellation(bps_payload)
     payload_mod = digital.chunks_to_symbols_bc(
         payload_constellation.points())
     payload_scrambler = digital.additive_scrambler_bb(
         0x8a,
         self.scramble_seed,
         7,
         0,  # Don't reset after fixed length (let the reset tag do that)
         bits_per_byte=8,  # This is before unpacking
         reset_tag_key=self.packet_length_tag_key)
     payload_unpack = blocks.repack_bits_bb(
         8,  # Unpack 8 bits per byte
         bps_payload,
         self.packet_length_tag_key)
     self.connect(crc, payload_scrambler, payload_unpack, payload_mod,
                  (header_payload_mux, 1))
     ### Create OFDM frame ################################################
     allocator = digital.ofdm_carrier_allocator_cvc(
         self.fft_len,
         occupied_carriers=self.occupied_carriers,
         pilot_carriers=self.pilot_carriers,
         pilot_symbols=self.pilot_symbols,
         sync_words=self.sync_words,
         len_tag_key=self.packet_length_tag_key)
     ffter = fft.fft_vcc(
         self.fft_len,
         False,  # Inverse FFT
         (),  # No window
         True  # Shift
     )
     cyclic_prefixer = mofdm.ofdm_cyclic_prefixer(
         self.fft_len, self.fft_len + self.cp_len, rolloff,
         self.packet_length_tag_key)
     self.connect(header_payload_mux, allocator, ffter, cyclic_prefixer,
                  self)
     if debug_log:
         self.connect(
             allocator,
             blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                              'tx-post-allocator.dat'))
         self.connect(
             cyclic_prefixer,
             blocks.file_sink(gr.sizeof_gr_complex, 'tx-signal.dat'))
Exemplo n.º 21
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()
        elif payload_mod == '8psk':
            self.payload_mod = payload_mod = digital.constellation_8psk()

        ##################################################
        # 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(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((.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")
Exemplo n.º 22
0
    def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
                 frame_length_tag_key=_def_frame_length_tag_key,
                 packet_length_tag_key=_def_packet_length_tag_key,
                 packet_num_tag_key=_def_packet_num_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,
                 debug_log=False,
                 scramble_bits=False
                 ):
        gr.hier_block2.__init__(self, "ofdm_rx",
                    gr.io_signature(1, 1, gr.sizeof_gr_complex),
                    gr.io_signature(2, 2, gr.sizeof_char))
        ### Param init / sanity check ########################################
        self.fft_len           = fft_len
        self.cp_len            = cp_len
        self.frame_length_tag_key    = frame_length_tag_key
        self.packet_length_tag_key   = packet_length_tag_key
        self.occupied_carriers = occupied_carriers
        self.bps_header        = bps_header
        self.bps_payload       = bps_payload
        n_sync_words = 1
        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_word1 = sync_word1
        self.sync_word2 = ()
        if sync_word2 is None:
            self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers)
            n_sync_words = 2
        elif len(sync_word2):
            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
        if scramble_bits:
            self.scramble_seed = 0x7f
        else:
            self.scramble_seed = 0x00 # We deactivate the scrambler by init'ing it with zeros
        ### Sync ############################################################
        sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
        delay = blocks.delay(gr.sizeof_gr_complex, fft_len+cp_len)
        oscillator = analog.frequency_modulator_fc(-2.0 / fft_len)
        mixer = blocks.multiply_cc()
        hpd = digital.header_payload_demux(
            n_sync_words+1,       # Number of OFDM symbols before payload (sync + 1 sym header)
            fft_len, cp_len,      # FFT length, guard interval
            frame_length_tag_key, # Frame length tag key
            "",                   # We're not using trigger tags
            True                  # One output item is one OFDM symbol (False would output complex scalars)
        )
        self.connect(self, sync_detect)
        self.connect(self, delay, (mixer, 0), (hpd, 0))
        self.connect((sync_detect, 0), oscillator, (mixer, 1))
        self.connect((sync_detect, 1), (hpd, 1))
        if debug_log:
            self.connect((sync_detect, 0), blocks.file_sink(gr.sizeof_float, 'freq-offset.dat'))
            self.connect((sync_detect, 1), blocks.file_sink(gr.sizeof_char, 'sync-detect.dat'))
        ### Header demodulation ##############################################
        header_fft           = fft.fft_vcc(self.fft_len, True, (), True)
        chanest              = digital.ofdm_chanest_vcvc(self.sync_word1, self.sync_word2, 1)
        header_constellation = _get_constellation(bps_header)
        header_equalizer     = digital.ofdm_equalizer_simpledfe(
            fft_len,
            header_constellation.base(),
            occupied_carriers,
            pilot_carriers,
            pilot_symbols,
            symbols_skipped=0,
        )
        header_eq = digital.ofdm_frame_equalizer_vcvc(
                header_equalizer.base(),
                cp_len,
                self.frame_length_tag_key,
                True,
                1 # Header is 1 symbol long
        )
        header_serializer = digital.ofdm_serializer_vcc(
                fft_len, occupied_carriers,
                self.frame_length_tag_key
        )
        header_demod     = digital.constellation_decoder_cb(header_constellation.base())
        header_formatter = digital.packet_header_ofdm(
                occupied_carriers, 1,
                packet_length_tag_key,
                frame_length_tag_key,
                packet_num_tag_key,
                bps_header,
                bps_payload,
                scramble_header=scramble_bits
        )
        header_parser = digital.packet_headerparser_b(header_formatter.formatter())
        self.connect(
                (hpd, 0),
                header_fft,
                chanest,
                header_eq,
                header_serializer,
                header_demod,
                header_parser
        )
        self.msg_connect(header_parser, "header_data", hpd, "header_data")
        if debug_log:
            self.connect((chanest, 1),      blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'channel-estimate.dat'))
            self.connect((chanest, 0),      blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'post-hdr-chanest.dat'))
            self.connect((chanest, 0),      blocks.tag_debug(gr.sizeof_gr_complex * fft_len, 'post-hdr-chanest'))
            self.connect(header_eq,         blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'post-hdr-eq.dat'))
            self.connect(header_serializer, blocks.file_sink(gr.sizeof_gr_complex,           'post-hdr-serializer.dat'))
            self.connect(header_descrambler, blocks.file_sink(1,                             'post-hdr-demod.dat'))
        ### Payload demod ####################################################
        payload_fft = fft.fft_vcc(self.fft_len, True, (), True)
        payload_constellation = _get_constellation(bps_payload)
        payload_equalizer = digital.ofdm_equalizer_simpledfe(
                fft_len,
                payload_constellation.base(),
                occupied_carriers,
                pilot_carriers,
                pilot_symbols,
                symbols_skipped=1, # (that was already in the header)
                alpha=0.1
        )
        payload_eq = digital.ofdm_frame_equalizer_vcvc(
                payload_equalizer.base(),
                cp_len,
                self.frame_length_tag_key
        )
        payload_serializer = digital.ofdm_serializer_vcc(
                fft_len, occupied_carriers,
                self.frame_length_tag_key,
                self.packet_length_tag_key,
                1 # Skip 1 symbol (that was already in the header)
        )
        payload_demod = digital.constellation_decoder_cb(payload_constellation.base())
        self.payload_descrambler = digital.additive_scrambler_bb(
            0x8a,
            self.scramble_seed,
            7,
            0, # Don't reset after fixed length
            bits_per_byte=8, # This is after packing
            reset_tag_key=self.packet_length_tag_key
        )
        payload_pack = blocks.repack_bits_bb(bps_payload, 8, self.packet_length_tag_key, True)
        self.crc = digital.crc32_bb(True, self.packet_length_tag_key)
        self.connect(
                (hpd, 1),
                payload_fft,
                payload_eq,
                payload_serializer,
                payload_demod,
                payload_pack,
                self.payload_descrambler,
                self.crc,
                self
        )
        self.connect((sync_detect, 1), (self, 1))

        # Add snr logger
        #snr = mofdm.ofdm_subchan_snr_vcvf(self.fft_len, self.cp_len, self.frame_length_tag_key,
        #    self.occupied_carriers, pilot_carriers, pilot_symbols, 0, True, debug=False)
        #self.connect(payload_fft, snr, blocks.file_sink(gr.sizeof_float * fft_len, 'perchan-snr.dat'))

        #rx_data = mofdm.ofdm_data_sink(self.packet_length_tag_key)
        #self.connect(self.payload_descrambler, rx_data)

        if debug_log:
            self.connect((hpd, 1),           blocks.tag_debug(gr.sizeof_gr_complex*fft_len, 'post-hpd'))
            self.connect(payload_fft,        blocks.file_sink(gr.sizeof_gr_complex*fft_len, 'post-payload-fft.dat'))
            self.connect(payload_eq,         blocks.file_sink(gr.sizeof_gr_complex*fft_len, 'post-payload-eq.dat'))
            self.connect(payload_serializer, blocks.file_sink(gr.sizeof_gr_complex,         'post-payload-serializer.dat'))
            self.connect(payload_demod,      blocks.file_sink(1,                            'post-payload-demod.dat'))
            self.connect(payload_pack,       blocks.file_sink(1,                            'post-payload-pack.dat'))
            self.connect(crc,                blocks.file_sink(1,                            'post-payload-crc.dat'))
Exemplo n.º 23
0
 def __init__(self, fft_len=_def_fft_len, cp_len=_def_cp_len,
              packet_length_tag_key=_def_packet_length_tag_key,
              occupied_carriers=_def_occupied_carriers,
              pilot_carriers=_def_pilot_carriers,
              pilot_symbols=_def_pilot_symbols,
              bps_header=1,
              bps_payload=1,
              sync_word1=None,
              sync_word2=None,
              rolloff=0,
              debug_log=False,
              scramble_bits=False
              ):
     gr.hier_block2.__init__(self, "ofdm_tx",
                 gr.io_signature(1, 1, gr.sizeof_char),
                 gr.io_signature(1, 1, gr.sizeof_gr_complex))
     ### Param init / sanity check ########################################
     self.fft_len           = fft_len
     self.cp_len            = cp_len
     self.packet_length_tag_key = packet_length_tag_key
     self.occupied_carriers = occupied_carriers
     self.pilot_carriers    = pilot_carriers
     self.pilot_symbols     = pilot_symbols
     self.bps_header        = bps_header
     self.bps_payload       = bps_payload
     self.sync_word1 = sync_word1
     if sync_word1 is None:
         self.sync_word1 = _make_sync_word1(fft_len, occupied_carriers, pilot_carriers)
     else:
         if len(sync_word1) != self.fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
     self.sync_words = [self.sync_word1,]
     if sync_word2 is None:
         self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers, pilot_carriers)
     else:
         self.sync_word2 = sync_word2
     if len(self.sync_word2):
         if len(self.sync_word2) != fft_len:
             raise ValueError("Length of sync sequence(s) must be FFT length.")
         self.sync_word2 = list(self.sync_word2)
         self.sync_words.append(self.sync_word2)
     if scramble_bits:
         self.scramble_seed = 0x7f
     else:
         self.scramble_seed = 0x00 # We deactivate the scrambler by init'ing it with zeros
     ### Header modulation ################################################
     crc = digital.crc32_bb(False, self.packet_length_tag_key)
     header_constellation  = _get_constellation(bps_header)
     header_mod = digital.chunks_to_symbols_bc(header_constellation.points())
     formatter_object = digital.packet_header_ofdm(
         occupied_carriers=occupied_carriers, n_syms=1,
         bits_per_header_sym=self.bps_header,
         bits_per_payload_sym=self.bps_payload,
         scramble_header=scramble_bits
     )
     header_gen = digital.packet_headergenerator_bb(formatter_object.base(), self.packet_length_tag_key)
     header_payload_mux = blocks.tagged_stream_mux(
             itemsize=gr.sizeof_gr_complex*1,
             lengthtagname=self.packet_length_tag_key,
             tag_preserve_head_pos=1 # Head tags on the payload stream stay on the head
     )
     self.connect(
             self,
             crc,
             header_gen,
             header_mod,
             (header_payload_mux, 0)
     )
     if debug_log:
         self.connect(header_gen, blocks.file_sink(1, 'tx-hdr.dat'))
     ### Payload modulation ###############################################
     payload_constellation = _get_constellation(bps_payload)
     payload_mod = digital.chunks_to_symbols_bc(payload_constellation.points())
     payload_scrambler = digital.additive_scrambler_bb(
         0x8a,
         self.scramble_seed,
         7,
         0, # Don't reset after fixed length (let the reset tag do that)
         bits_per_byte=8, # This is before unpacking
         reset_tag_key=self.packet_length_tag_key
     )
     payload_unpack = blocks.repack_bits_bb(
         8, # Unpack 8 bits per byte
         bps_payload,
         self.packet_length_tag_key
     )
     self.connect(
         crc,
         payload_scrambler,
         payload_unpack,
         payload_mod,
         (header_payload_mux, 1)
     )
     ### Create OFDM frame ################################################
     allocator = digital.ofdm_carrier_allocator_cvc(
         self.fft_len,
         occupied_carriers=self.occupied_carriers,
         pilot_carriers=self.pilot_carriers,
         pilot_symbols=self.pilot_symbols,
         sync_words=self.sync_words,
         len_tag_key=self.packet_length_tag_key
     )
     ffter = fft.fft_vcc(
             self.fft_len,
             False, # Inverse FFT
             (), # No window
             True # Shift
     )
     cyclic_prefixer = mofdm.ofdm_cyclic_prefixer(
         self.fft_len,
         self.fft_len+self.cp_len,
         rolloff,
         self.packet_length_tag_key
     )
     self.connect(header_payload_mux, allocator, ffter, cyclic_prefixer, self)
     if debug_log:
         self.connect(allocator,       blocks.file_sink(gr.sizeof_gr_complex * fft_len, 'tx-post-allocator.dat'))
         self.connect(cyclic_prefixer, blocks.file_sink(gr.sizeof_gr_complex,           'tx-signal.dat'))
Exemplo n.º 24
0
    def __init__(self, bfo=12000, ip='127.0.0.1', port=7355, recstart=''):
        gr.top_block.__init__(self, "Taurus-1 decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Taurus-1 decoder")
        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", "taurus1")
        self.restoreGeometry(
            self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Parameters
        ##################################################
        self.bfo = bfo
        self.ip = ip
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.samp_per_sym = samp_per_sym = 5
        self.nfilts = nfilts = 16
        self.alpha = alpha = 0.35

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.threshold = threshold = 3
        self.samp_rate = samp_rate = 48000
        self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(samp_per_sym), 0.35,
            11 * samp_per_sym * nfilts)
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts)
        self.nfilts_0 = nfilts_0 = 16
        self.equalizer_gain = equalizer_gain = 0.05
        self.af_gain = af_gain = 0

        ##################################################
        # Blocks
        ##################################################
        self._equalizer_gain_range = Range(0.0, 0.2, 0.01, 0.05, 200)
        self._equalizer_gain_win = RangeWidget(self._equalizer_gain_range,
                                               self.set_equalizer_gain,
                                               'Equalizer: Gain',
                                               "counter_slider", float)
        self.top_grid_layout.addWidget(self._equalizer_gain_win)
        self._af_gain_tool_bar = Qt.QToolBar(self)
        self._af_gain_tool_bar.addWidget(Qt.QLabel('AF Gain' + ": "))
        self._af_gain_line_edit = Qt.QLineEdit(str(self.af_gain))
        self._af_gain_tool_bar.addWidget(self._af_gain_line_edit)
        self._af_gain_line_edit.returnPressed.connect(lambda: self.set_af_gain(
            eng_notation.str_to_num(
                str(self._af_gain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._af_gain_tool_bar)
        self.satellites_taurus1_telemetry_parser_0 = satellites.taurus1_telemetry_parser(
        )
        self.satellites_submit_0 = satellites.submit(
            'https://db.satnogs.org/api/telemetry/', 44530, 'AD7NP', -122.2084,
            47.6458, recstart)
        self.satellites_print_timestamp_0 = satellites.print_timestamp(
            '%Y-%m-%d %H:%M:%S', True)
        self.satellites_lilacsat1_demux_0_0 = satellites.lilacsat1_demux(
            "syncword")
        self.satellites_lilacsat1_demux_0 = satellites.lilacsat1_demux(
            "syncword")
        self.satellites_kiss_to_pdu_1 = satellites.kiss_to_pdu(False)
        self.rms_agc_0 = rms_agc(
            alpha=1e-2,
            reference=0.5,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
            interpolation=6,
            decimation=1,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            1000,  #size
            8000,  #samp_rate
            "",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.125)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(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_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 = ['A', 'B', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1,
                                       2)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 6000, 500, firdes.WIN_HAMMING, 6.76))
        self.lilacsat_vitfilt27_fb_0_0 = lilacsat.vitfilt27_fb()
        self.lilacsat_vitfilt27_fb_0 = lilacsat.vitfilt27_fb()
        self.lilacsat_sync_det_b_0_0 = lilacsat.sync_det_b(
            0x1ACFFC1D, 116, True, True)
        self.lilacsat_sync_det_b_0 = lilacsat.sync_det_b(
            0x1ACFFC1D, 116, True, True)
        self.lilacsat_lilacsat1_frame_depack_0 = lilacsat.lilacsat1_frame_depack(
        )
        (self.lilacsat_lilacsat1_frame_depack_0).set_max_output_buffer(512)
        self.lilacsat_codec2_decode_bf_0 = lilacsat.codec2_decode_bf(0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf(
            1, (firdes.low_pass(1, samp_rate, 10000, 1000)), bfo, samp_rate)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.05, (rrc_taps), nfilts, nfilts / 2, 0.01, 1)
        self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc(
            2, equalizer_gain, 2, variable_constellation_0)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            sps, 0.350, 100, 0.01)
        self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(0.1, 2, False)
        self.digital_correlate_access_code_tag_bb_0_0_0_0_0 = digital.correlate_access_code_tag_bb(
            "00011010110011111111110000011101", threshold, "syncword")
        self.digital_correlate_access_code_tag_bb_0_0_0_0 = digital.correlate_access_code_tag_bb(
            "00011010110011111111110000011101", threshold, "syncword")
        self.digital_additive_scrambler_bb_0_0_0_0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key="syncword")
        self.digital_additive_scrambler_bb_0_0_0 = digital.additive_scrambler_bb(
            0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key="syncword")
        self.ccsds_viterbi_0_0 = ccsds_viterbi()
        self.ccsds_viterbi_0 = ccsds_viterbi()
        self.blocks_unpacked_to_packed_xx_0_0_0_0_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_unpacked_to_packed_xx_0_0_0_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_unpack_k_bits_bb_0_0_0_1 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip,
                                                     port, 1472, False)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 '127.0.0.1', 7000, 7, False)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, 8000,
                                                 True)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767)
        self.blocks_pdu_to_tagged_stream_1_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff(
            (10.0**(af_gain / 20.0), ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.audio_source_0 = audio.source(8000, '', True)
        self.audio_sink_0 = audio.sink(48000, '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.lilacsat_lilacsat1_frame_depack_0, 'out'),
                         (self.blocks_message_debug_0, 'store'))
        self.msg_connect((self.lilacsat_sync_det_b_0, 'out'),
                         (self.lilacsat_lilacsat1_frame_depack_0, 'in'))
        self.msg_connect((self.lilacsat_sync_det_b_0_0, 'out'),
                         (self.lilacsat_lilacsat1_frame_depack_0, 'in'))
        self.msg_connect((self.satellites_kiss_to_pdu_1, 'out'),
                         (self.satellites_print_timestamp_0, 'in'))
        self.msg_connect((self.satellites_kiss_to_pdu_1, 'out'),
                         (self.satellites_submit_0, 'in'))
        self.msg_connect((self.satellites_lilacsat1_demux_0, 'kiss'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.satellites_lilacsat1_demux_0, 'codec2'),
                         (self.blocks_pdu_to_tagged_stream_1_0, 'pdus'))
        self.msg_connect((self.satellites_lilacsat1_demux_0_0, 'kiss'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.satellites_lilacsat1_demux_0_0, 'codec2'),
                         (self.blocks_pdu_to_tagged_stream_1_0, 'pdus'))
        self.msg_connect((self.satellites_print_timestamp_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_print_timestamp_0, 'out'),
                         (self.satellites_taurus1_telemetry_parser_0, 'in'))
        self.connect((self.audio_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.ccsds_viterbi_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_complex_to_real_0_0, 0),
                     (self.lilacsat_vitfilt27_fb_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.ccsds_viterbi_0_0, 0))
        self.connect((self.blocks_delay_0_0, 0),
                     (self.lilacsat_vitfilt27_fb_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_1, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0_0_0_0, 0))
        self.connect((self.blocks_short_to_float_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0_0, 0),
                     (self.lilacsat_sync_det_b_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0_0_1, 0),
                     (self.lilacsat_sync_det_b_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
                     (self.satellites_kiss_to_pdu_1, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0_0, 0),
                     (self.blocks_udp_sink_0, 0))
        self.connect((self.ccsds_viterbi_0, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.ccsds_viterbi_0_0, 0),
                     (self.digital_diff_decoder_bb_0_0, 0))
        self.connect((self.digital_additive_scrambler_bb_0_0_0, 0),
                     (self.satellites_lilacsat1_demux_0, 0))
        self.connect((self.digital_additive_scrambler_bb_0_0_0_0, 0),
                     (self.satellites_lilacsat1_demux_0_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0_0_0_0, 0),
                     (self.digital_additive_scrambler_bb_0_0_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0_0_0_0_0, 0),
                     (self.digital_additive_scrambler_bb_0_0_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.blocks_complex_to_real_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0_0_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0_0, 0),
                     (self.digital_correlate_access_code_tag_bb_0_0_0_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.rms_agc_0, 0))
        self.connect((self.lilacsat_codec2_decode_bf_0, 0),
                     (self.blocks_multiply_const_vxx_1, 0))
        self.connect((self.lilacsat_codec2_decode_bf_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.lilacsat_lilacsat1_frame_depack_0, 0),
                     (self.lilacsat_codec2_decode_bf_0, 0))
        self.connect((self.lilacsat_vitfilt27_fb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0_0, 0))
        self.connect((self.lilacsat_vitfilt27_fb_0_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0_0_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.audio_sink_0, 0))
        self.connect((self.rms_agc_0, 0), (self.digital_fll_band_edge_cc_0, 0))
Exemplo n.º 25
0
    def __init__(self,
                 fft_len=_def_fft_len,
                 cp_len=_def_cp_len,
                 frame_length_tag_key=_def_frame_length_tag_key,
                 packet_length_tag_key=_def_packet_length_tag_key,
                 packet_num_tag_key=_def_packet_num_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,
                 debug_log=False,
                 scramble_bits=False):
        gr.hier_block2.__init__(self, "ofdm_rx",
                                gr.io_signature(1, 1, gr.sizeof_gr_complex),
                                gr.io_signature(2, 2, gr.sizeof_char))
        ### Param init / sanity check ########################################
        self.fft_len = fft_len
        self.cp_len = cp_len
        self.frame_length_tag_key = frame_length_tag_key
        self.packet_length_tag_key = packet_length_tag_key
        self.occupied_carriers = occupied_carriers
        self.bps_header = bps_header
        self.bps_payload = bps_payload
        n_sync_words = 1
        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_word1 = sync_word1
        self.sync_word2 = ()
        if sync_word2 is None:
            self.sync_word2 = _make_sync_word2(fft_len, occupied_carriers,
                                               pilot_carriers)
            n_sync_words = 2
        elif len(sync_word2):
            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
        if scramble_bits:
            self.scramble_seed = 0x7f
        else:
            self.scramble_seed = 0x00  # We deactivate the scrambler by init'ing it with zeros
        ### Sync ############################################################
        sync_detect = digital.ofdm_sync_sc_cfb(fft_len, cp_len)
        delay = blocks.delay(gr.sizeof_gr_complex, fft_len + cp_len)
        oscillator = analog.frequency_modulator_fc(-2.0 / fft_len)
        mixer = blocks.multiply_cc()
        hpd = digital.header_payload_demux(
            n_sync_words +
            1,  # Number of OFDM symbols before payload (sync + 1 sym header)
            fft_len,
            cp_len,  # FFT length, guard interval
            frame_length_tag_key,  # Frame length tag key
            "",  # We're not using trigger tags
            True  # One output item is one OFDM symbol (False would output complex scalars)
        )
        self.connect(self, sync_detect)
        self.connect(self, delay, (mixer, 0), (hpd, 0))
        self.connect((sync_detect, 0), oscillator, (mixer, 1))
        self.connect((sync_detect, 1), (hpd, 1))
        if debug_log:
            self.connect((sync_detect, 0),
                         blocks.file_sink(gr.sizeof_float, 'freq-offset.dat'))
            self.connect((sync_detect, 1),
                         blocks.file_sink(gr.sizeof_char, 'sync-detect.dat'))
        ### Header demodulation ##############################################
        header_fft = fft.fft_vcc(self.fft_len, True, (), True)
        chanest = digital.ofdm_chanest_vcvc(self.sync_word1, self.sync_word2,
                                            1)
        header_constellation = _get_constellation(bps_header)
        header_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len,
            header_constellation.base(),
            occupied_carriers,
            pilot_carriers,
            pilot_symbols,
            symbols_skipped=0,
        )
        header_eq = digital.ofdm_frame_equalizer_vcvc(
            header_equalizer.base(),
            cp_len,
            self.frame_length_tag_key,
            True,
            1  # Header is 1 symbol long
        )
        header_serializer = digital.ofdm_serializer_vcc(
            fft_len, occupied_carriers, self.frame_length_tag_key)
        header_demod = digital.constellation_decoder_cb(
            header_constellation.base())
        header_formatter = digital.packet_header_ofdm(
            occupied_carriers,
            1,
            packet_length_tag_key,
            frame_length_tag_key,
            packet_num_tag_key,
            bps_header,
            bps_payload,
            scramble_header=scramble_bits)
        header_parser = digital.packet_headerparser_b(
            header_formatter.formatter())
        self.connect((hpd, 0), header_fft, chanest, header_eq,
                     header_serializer, header_demod, header_parser)
        self.msg_connect(header_parser, "header_data", hpd, "header_data")
        if debug_log:
            self.connect((chanest, 1),
                         blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                                          'channel-estimate.dat'))
            self.connect((chanest, 0),
                         blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                                          'post-hdr-chanest.dat'))
            self.connect((chanest, 0),
                         blocks.tag_debug(gr.sizeof_gr_complex * fft_len,
                                          'post-hdr-chanest'))
            self.connect(
                header_eq,
                blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                                 'post-hdr-eq.dat'))
            self.connect(
                header_serializer,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 'post-hdr-serializer.dat'))
            self.connect(header_descrambler,
                         blocks.file_sink(1, 'post-hdr-demod.dat'))
        ### Payload demod ####################################################
        payload_fft = fft.fft_vcc(self.fft_len, True, (), True)
        payload_constellation = _get_constellation(bps_payload)
        payload_equalizer = digital.ofdm_equalizer_simpledfe(
            fft_len,
            payload_constellation.base(),
            occupied_carriers,
            pilot_carriers,
            pilot_symbols,
            symbols_skipped=1,  # (that was already in the header)
            alpha=0.1)
        payload_eq = digital.ofdm_frame_equalizer_vcvc(
            payload_equalizer.base(), cp_len, self.frame_length_tag_key)
        payload_serializer = digital.ofdm_serializer_vcc(
            fft_len,
            occupied_carriers,
            self.frame_length_tag_key,
            self.packet_length_tag_key,
            1  # Skip 1 symbol (that was already in the header)
        )
        payload_demod = digital.constellation_decoder_cb(
            payload_constellation.base())
        self.payload_descrambler = digital.additive_scrambler_bb(
            0x8a,
            self.scramble_seed,
            7,
            0,  # Don't reset after fixed length
            bits_per_byte=8,  # This is after packing
            reset_tag_key=self.packet_length_tag_key)
        payload_pack = blocks.repack_bits_bb(bps_payload, 8,
                                             self.packet_length_tag_key, True)
        self.crc = digital.crc32_bb(True, self.packet_length_tag_key)
        self.connect((hpd, 1), payload_fft, payload_eq, payload_serializer,
                     payload_demod, payload_pack, self.payload_descrambler,
                     self.crc, self)
        self.connect((sync_detect, 1), (self, 1))

        # Add snr logger
        #snr = mofdm.ofdm_subchan_snr_vcvf(self.fft_len, self.cp_len, self.frame_length_tag_key,
        #    self.occupied_carriers, pilot_carriers, pilot_symbols, 0, True, debug=False)
        #self.connect(payload_fft, snr, blocks.file_sink(gr.sizeof_float * fft_len, 'perchan-snr.dat'))

        #rx_data = mofdm.ofdm_data_sink(self.packet_length_tag_key)
        #self.connect(self.payload_descrambler, rx_data)

        if debug_log:
            self.connect((hpd, 1),
                         blocks.tag_debug(gr.sizeof_gr_complex * fft_len,
                                          'post-hpd'))
            self.connect(
                payload_fft,
                blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                                 'post-payload-fft.dat'))
            self.connect(
                payload_eq,
                blocks.file_sink(gr.sizeof_gr_complex * fft_len,
                                 'post-payload-eq.dat'))
            self.connect(
                payload_serializer,
                blocks.file_sink(gr.sizeof_gr_complex,
                                 'post-payload-serializer.dat'))
            self.connect(payload_demod,
                         blocks.file_sink(1, 'post-payload-demod.dat'))
            self.connect(payload_pack,
                         blocks.file_sink(1, 'post-payload-pack.dat'))
            self.connect(crc, blocks.file_sink(1, 'post-payload-crc.dat'))
Exemplo n.º 26
0
    def __init__(self):
        gr.top_block.__init__(self, "OPS-SAT UHF demodulator/decoder")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OPS-SAT UHF demodulator/decoder")
        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", "os_demod_decode")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 57600
        self.baud_rate = baud_rate = 9600
        self.gaussian_taps = gaussian_taps = firdes.gaussian(
            1.5, 2 * (samp_rate / baud_rate), 0.5, 12)
        self.gain_mu = gain_mu = 0.175

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1,
                                                     'tcp://127.0.0.1:5555',
                                                     100, False, -1)
        self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1,
                                                 'tcp://127.0.0.1:38211', 100,
                                                 False, -1)
        self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header()
        self.satellites_nrzi_decode_0 = satellites.nrzi_decode()
        self.satellites_hdlc_deframer_0_0 = satellites.hdlc_deframer(
            check_fcs=True, max_length=1000)
        self.satellites_decode_rs_0 = satellites.decode_rs(True, 0)
        self.satellites_check_address_0 = satellites.check_address(
            'DP0OPS', "from")
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            512,  #size
            firdes.WIN_HAMMING,  #wintype
            0,  #fc
            samp_rate,  #bw
            "OPS-SAT UHF BEACON",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.03)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

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

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

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            512,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(0.1)
        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.fir_filter_xxx_0 = filter.fir_filter_fff(1, (gaussian_taps))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_descrambler_bb_0_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            (samp_rate / baud_rate) * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5,
            gain_mu, 0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb(
            0xA9,
            0xFF,
            7,
            count=0,
            bits_per_byte=1,
            reset_tag_key="packet_len")
        self.blocks_unpacked_to_packed_xx_0_0_0_0 = blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_1 = 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_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(
            2 * (samp_rate / baud_rate) / (math.pi))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'),
                         (self.satellites_decode_rs_0, 'in'))
        self.msg_connect((self.satellites_check_address_0, 'ok'),
                         (self.satellites_strip_ax25_header_0, 'in'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.satellites_decode_rs_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_1, 'pdus'))
        self.msg_connect((self.satellites_hdlc_deframer_0_0, 'out'),
                         (self.satellites_check_address_0, 'in'))
        self.msg_connect((self.satellites_strip_ax25_header_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_additive_scrambler_bb_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_1, 0),
                     (self.zeromq_pub_sink_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0))
        self.connect((self.digital_additive_scrambler_bb_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.satellites_nrzi_decode_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0_0, 0),
                     (self.satellites_hdlc_deframer_0_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.satellites_nrzi_decode_0, 0),
                     (self.digital_descrambler_bb_0_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.zeromq_sub_source_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
Exemplo n.º 27
0
 def __init__(self):
     gr.hier_block2.__init__(self, "ofdm_tx",
                             gr.io_signature(1, 1, gr.sizeof_gr_complex),
                             gr.io_signature(1, 1, gr.sizeof_char))
     self.constellationP = helpers.get_constellation(settings.PAYLOAD_BPS)
     self.constellationH = helpers.get_constellation(settings.HEADER_BPS)
     detector = digital.ofdm_sync_sc_cfb(symbol_settings.get_fft_length(),
                                         symbol_settings.get_cp_length(),
                                         True)
     self.connect((detector, 0),
                  blocks.file_sink(gr.sizeof_float, "offset.dat"))
     delayer = blocks.delay(gr.sizeof_gr_complex,
                            symbol_settings.get_time_length_of_symbol() + 5)
     oscillator = analog.frequency_modulator_fc(
         -2.0 / symbol_settings.get_fft_length())
     splitter = digital.header_payload_demux(
         3,
         symbol_settings.get_fft_length(),
         symbol_settings.get_cp_length(),
         settings.LENGTH_TAG_KEY,
         "",
         True,
     )
     mixer = blocks.multiply_cc()
     self.connect(
         mixer, blocks.file_sink(gr.sizeof_gr_complex, "mixer_output.dat"))
     header_fft = fft.fft_vcc(symbol_settings.get_fft_length(), True, (),
                              True)
     chanest = digital.ofdm_chanest_vcvc(SYNC_ONE, SYNC_TWO, 1)
     #self.connect((chanest, 1),blocks.file_sink(gr.sizeof_gr_complex * symbol_settings.get_fft_length(), 'channel-estimate.dat'))
     header_equalizer = digital.ofdm_equalizer_simpledfe(
         symbol_settings.get_fft_length(),
         self.constellationH.base(),
         symbol_settings.get_carrier_tones(),
         symbol_settings.get_pilot_tones(),
         SYM_PILOT,
         symbols_skipped=0,
     )
     header_eq = digital.ofdm_frame_equalizer_vcvc(
         header_equalizer.base(),
         symbol_settings.get_cp_length(),
         settings.LENGTH_TAG_KEY,
         True,
         1  # Header is 1 symbol long
     )
     header_serializer = digital.ofdm_serializer_vcc(
         symbol_settings.get_fft_length(),
         symbol_settings.get_carrier_tones(), settings.LENGTH_TAG_KEY)
     header_demod = digital.constellation_decoder_cb(
         self.constellationH.base())
     header_repack = blocks.repack_bits_bb(settings.HEADER_BPS, 8,
                                           settings.LENGTH_TAG_KEY, True)
     scramblerH = digital.digital.additive_scrambler_bb(
         0x8a,
         settings.SCRAMBLED_SEED,
         7,
         0,
         bits_per_byte=8,
         reset_tag_key=settings.LENGTH_HEADER_KEY)
     self.connect(scramblerH, blocks.file_sink(gr.sizeof_char,
                                               "header.dat"))
     parser = ownHeader.parse_header_bb(settings.LENGTH_HEADER_KEY,
                                        settings.LENGTH_TAG_KEY, 3, 1, 0)
     framer_0 = framer.blk(6, settings.LENGTH_HEADER_KEY)
     sender = ownHeader.send_to_multiplexer_b(settings.LENGTH_HEADER_KEY)
     payload_fft = fft.fft_vcc(symbol_settings.get_fft_length(), True, (),
                               True)
     payload_equalizer = digital.ofdm_equalizer_simpledfe(
         symbol_settings.get_fft_length(),
         self.constellationP.base(),
         symbol_settings.get_carrier_tones(),
         symbol_settings.get_pilot_tones(),
         SYM_PILOT,
         symbols_skipped=1,  # (that was already in the header)
         alpha=0.1)
     #self.connect(mixer, blocks.tag_debug(gr.sizeof_gr_complex, "header"))
     #self.connect(payload_fft, blocks.tag_debug(gr.sizeof_gr_complex*64, "payload"))
     payload_eq = digital.ofdm_frame_equalizer_vcvc(
         payload_equalizer.base(), symbol_settings.get_cp_length(),
         settings.LENGTH_TAG_KEY)
     payload_serializer = digital.ofdm_serializer_vcc(
         symbol_settings.get_fft_length(),
         symbol_settings.get_carrier_tones(),
         settings.LENGTH_TAG_KEY,
         settings.LENGTH_PACKET_KEY,
         1  # Skip 1 symbol (that was already in the header)
     )
     payload_demod = digital.constellation_decoder_cb(
         self.constellationP.base())
     payload_descrambler = digital.additive_scrambler_bb(
         0x8a,
         settings.SCRAMBLED_SEED,
         7,
         0,  # Don't reset after fixed length
         bits_per_byte=8,  # This is after packing
         reset_tag_key=settings.LENGTH_PACKET_KEY)
     payload_pack = blocks.repack_bits_bb(settings.PAYLOAD_BPS, 8,
                                          settings.LENGTH_PACKET_KEY, True)
     crc = digital.crc32_bb(True, settings.LENGTH_PACKET_KEY)
     gate = blocks.tag_gate(gr.sizeof_gr_complex, False)
     """
                 detecting the the preamble
             """
     self.connect(self, detector)
     self.connect(self, delayer, (mixer, 0))
     self.connect(gate, (splitter, 0))
     self.connect(mixer, gate)
     #self.connect(delayer, (splitter,0))
     self.connect((detector, 0), oscillator, (mixer, 1))
     self.connect((detector, 1), (splitter, 1))
     #header handling stream
     """
             parse the header data
             """
     self.connect((splitter, 0), header_fft, chanest, header_eq,
                  header_serializer, header_demod, header_repack, framer_0,
                  scramblerH, parser, sender)
     self.msg_connect(sender, "header", splitter,
                      "header_data")  #feedback to the demux
     #data handler stream
     """
                 retrieve the data
             """
     self.connect((splitter, 1), payload_fft, payload_eq,
                  payload_serializer, payload_demod, payload_pack,
                  payload_descrambler, crc, self)