コード例 #1
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.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'))
コード例 #2
0
    def test_003(self):
        # Test that block stops when interacting with streaming interface
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x73, 0x75, 0x63, 0x68, 0x74, 0x65, 0x73, 0x74, 0x76, 0x65,
                   0x72, 0x79, 0x70, 0x61, 0x73, 0x73)
        tag_dict = {"offset": 0}
        tag_dict["key"] = pmt.intern("len")
        tag_dict["value"] = pmt.from_long(8)
        tag1 = gr.python_to_tag(tag_dict)
        tag_dict["offset"] = 8
        tag2 = gr.python_to_tag(tag_dict)
        tags = [tag1, tag2]

        src = blocks.vector_source_b(srcdata, False, 1, tags)
        ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len")
        pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141")
        #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len")
        head = blocks.head(gr.sizeof_char, 10)
        sink = blocks.vector_sink_b(1)

        self.tb.connect(src, ts_to_pdu)
        self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus")
        # a UDP socket connects pdu_send to pdu_recv
        # TODO: test that the recv socket can be destroyed from downstream
        # that signals DONE. Also that we get the PDUs we sent
        #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus")
        #self.tb.connect(pdu_to_ts, head, sink)
        self.tb.run()
コード例 #3
0
    def test_001_t(self):
        # set up fg
        pkt_tag = gr.tag_t()
        pkt_tag.key = pmt.intern("pkt")
        mod_types = ['BPSK', 'QPSK', '8PSK', 'QAM16', 'QAM64']
        for mod_type in mod_types:
            print("Testing {}...".format(mod_type))
            modulator = modulator_classic(mod_type)
            src_data = get_random_bits(100 * modulator.bits_per_symbol)
            pkt_tag.value = pmt.to_pmt(len(src_data))
            expected_data = modulator.modulate(
                bits_to_integers(data_b=src_data,
                                 bits_per_symbol=modulator.bits_per_symbol))
            src = blocks.vector_source_b(src_data, False, 1, [pkt_tag])
            tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt")
            pdu2tag = blocks.pdu_to_tagged_stream(blocks.complex_t, "pkt")
            snk = blocks.vector_sink_c()
            self.tb.connect(src, tag2pdu)
            self.tb.msg_connect(tag2pdu, "pdus", modulator, "bits")
            self.tb.msg_connect(modulator, "symbols", pdu2tag, "pdus")
            self.tb.connect(pdu2tag, snk)

            self.tb.start()
            while modulator.packet_cnt < 1:
                time.sleep(0.1)
            self.tb.stop()
            self.tb.wait()
            # check data
            result_data = snk.data()
            self.assertComplexTuplesAlmostEqual(expected_data, result_data, 6)
コード例 #4
0
 def test_001_t(self):
     print("Enable plotting to manually verify result of wrapping")
     body = get_random_bits(256)
     src = tvsb(body.astype(numpy.int8), None, True, "body")
     mod = modulator_classic("BPSK")
     wrapper = echo_packet_wrapper(self.nfreq_samps, self.freqs,
                                   self.corr_reps)
     sink = blocks.vector_sink_c()
     pdu2strm = blocks.pdu_to_tagged_stream(blocks.complex_t, "frame")
     strm2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "body")
     # Connect blocks
     self.tb.connect(src, strm2pdu)
     self.tb.connect(pdu2strm, sink)
     self.tb.msg_connect(strm2pdu, "pdus", mod, "bits")
     self.tb.msg_connect(mod, "symbols", wrapper, "body")
     self.tb.msg_connect(wrapper, "frame", pdu2strm, "pdus")
     # Run
     self.tb.start()
     while wrapper.npackets < 1:
         time.sleep(0.1)
     self.tb.stop()
     self.tb.wait()
     # check data
     result = sink.data()
     # self.plot_outcome(result)
     self.assertEqual(len(result),
                      self.nfreq_samps + 2 * self.corr_reps * 256 + 256,
                      "Incorrect number of output bits")
コード例 #5
0
ファイル: strobe.py プロジェクト: mbr0wn/gr-fosdem
    def __init__(self):
        gr.top_block.__init__(self, "Strobe")

        ##################################################
        # Blocks
        ##################################################
        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")
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(64,0) ), 750)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_copy_0 = blocks.copy(gr.sizeof_char*1)
        self.blocks_copy_0.set_enabled(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_copy_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_copy_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_message_debug_0, "print")
        self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus", self.blocks_message_debug_0, "print_pdu")
コード例 #6
0
    def setUp(self):
        self.tb = gr.top_block()
        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32e3
        self.preamble = preamble = get_random_bits(64 * 3)
        self.npreamble = len(self.preamble)
        # self.modulation = modulation = "QPSK"
        self.nbits = 16 * 3
        self.bits = get_random_bits(self.nbits)
        self.tag_preamble = gr.tag_t()
        self.tag_preamble.key = pmt.intern("pkt")
        self.tag_preamble.value = pmt.from_long(self.npreamble)
        self.tag_preamble.offset = 0
        self.tag_body = gr.tag_t()
        self.tag_body.key = pmt.intern("pkt")
        self.tag_body.value = pmt.from_long(self.nbits)

        ##################################################
        # Blocks
        ##################################################
        # self.modulator = modulator_classic(modulation)
        # self.demodulator = demodulator_neural(seed=0, hidden_layers=(64, ), bits_per_symbol=2, preamble=preamble)
        self.vector_source_preamble = blocks.vector_source_b(
            preamble, True, 1, [self.tag_preamble])
        self.vector_source_body = blocks.vector_source_b(
            self.bits, True, 1, [self.tag_body])
        self.tags_mux = blocks.tagged_stream_mux(gr.sizeof_char * 1, "pkt")
        self.strm_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt")
        self.pdu_to_strm = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt")
        self.vector_sink = blocks.vector_sink_b()
コード例 #7
0
ファイル: ofdm_phy.py プロジェクト: panchenglong/gr-mofdm
    def __init__(self):
        gr.hier_block2.__init__(
            self, "OFDM PHY",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature2(2, 2, gr.sizeof_gr_complex * 1, gr.sizeof_char))
        
        # Message Port
        self.message_port_register_hier_out("from_mac")
        self.message_port_register_hier_in("to_mac")

        # Blocks
        self.tx_pdu = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_length")
        self.tx_path = ofdm_tx(scramble_bits=True)

        self.rx_path = ofdm_rx(scramble_bits=True)
        self.rx_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_length")

        # Connections
        self.connect(self.tx_pdu, self.tx_path, self)
        self.connect(self, self.rx_path, self.rx_pdu)
        self.connect((self.rx_path, 1), (self, 1))

        # Message Connection
        self.msg_connect(self, "from_mac", self.tx_pdu, "pdus")
        self.msg_connect(self.rx_pdu, "pdus", self, "to_mac")
コード例 #8
0
 def test_001_t (self):
     # set up fg
     phr = np.random.randint(0,2,size=(12,))
     data = np.array(np.random.randint(0,256, size=(6*3,)))
     data_bin = np.unpackbits(np.array(data,dtype=np.uint8))
     self.src = blocks.vector_source_b(data, False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 6, "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.pref = ieee802_15_4.phr_prefixer(phr)
     self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
     self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.pref, "in")
     self.tb.msg_connect(self.pref, "out", self.pdu2ts, "pdus")
     self.tb.connect(self.pdu2ts, self.snk)
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     # check data
     data_out = self.snk.data()
     # print "input:"
     # for i in data:
     # 	print i
     # print "output:"
     # for i in data_out:
     # 	print data_out
     expected_output = np.concatenate((phr,data_bin[0:6*8], phr, data_bin[6*8:12*8], phr, data_bin[12*8:18*8]))
     self.assertFloatTuplesAlmostEqual(data_out, expected_output)
コード例 #9
0
ファイル: strobe.py プロジェクト: mbr0wn/gr-fosdem
    def __init__(self):
        gr.top_block.__init__(self, "Strobe")

        ##################################################
        # Blocks
        ##################################################
        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")
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(64, 0)), 750)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_copy_0 = blocks.copy(gr.sizeof_char * 1)
        self.blocks_copy_0.set_enabled(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_copy_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_copy_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_message_strobe_0, "strobe",
                         self.blocks_message_debug_0, "print")
        self.msg_connect(self.blocks_message_strobe_0_0, "strobe",
                         self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus",
                         self.blocks_message_debug_0, "print_pdu")
コード例 #10
0
    def __init__(self):
        gr.top_block.__init__(self, "Bit Padding Test")

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

        ##################################################
        # Blocks
        ##################################################
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_random_pdu_0 = blocks.random_pdu(10, 12, chr(0xFF), 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
コード例 #11
0
ファイル: qa_sym_enc.py プロジェクト: Radiomix2000/gr-openssl
    def test_001_t(self):

        cipher_name = "aes-256-cbc"
        plainlen = 1600
        packet_len = 1600
        key = bytearray(numpy.random.randint(0, 256, 32).tolist())
        plain = bytearray(numpy.random.randint(0, 256, plainlen).tolist())

        cipher_desc = crypto.sym_ciph_desc(cipher_name, False, key)
        src = blocks.vector_source_b(plain)
        stts = blocks.stream_to_tagged_stream(1, 1, packet_len, "packet_len")
        tstpdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        enc = crypto.sym_enc(cipher_desc)
        dec = crypto.sym_dec(cipher_desc)
        snk = blocks.message_debug()

        self.tb.connect(src, stts, tstpdu)
        self.tb.msg_connect(tstpdu, "pdus", enc, "pdus")
        self.tb.msg_connect(enc, "pdus", dec, "pdus")
        self.tb.msg_connect(dec, "pdus", snk, "store")

        self.tb.run()

        num_msg = snk.num_messages()
        decrypted = bytearray(
            pmt.u8vector_elements(pmt.cdr((snk.get_message(0)))))
        self.assertEqual(plain, decrypted)
コード例 #12
0
 def test_001_t(self):
     # set up fg
     phr = np.random.randint(0, 2, size=(12, ))
     data = np.array(np.random.randint(0, 256, size=(6 * 3, )))
     data_bin = np.unpackbits(np.array(data, dtype=np.uint8))
     self.src = blocks.vector_source_b(data, False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 6,
                                                "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.pref = ieee802_15_4.phr_prefixer(phr)
     self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
     self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.pref, "in")
     self.tb.msg_connect(self.pref, "out", self.pdu2ts, "pdus")
     self.tb.connect(self.pdu2ts, self.snk)
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     # check data
     data_out = self.snk.data()
     # print "input:"
     # for i in data:
     # 	print i
     # print "output:"
     # for i in data_out:
     # 	print data_out
     expected_output = np.concatenate(
         (phr, data_bin[0:6 * 8], phr, data_bin[6 * 8:12 * 8], phr,
          data_bin[12 * 8:18 * 8]))
     self.assertFloatTuplesAlmostEqual(data_out, expected_output)
コード例 #13
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))
コード例 #14
0
 def test_filtered_keep_t(self):
     print("Filtered Keep Test")
     bits = util_data.get_random_bits(100).astype(np.int8)
     source = tvsb(data=bits,
                   triggers=["DEBUG"],
                   initial_trigger=True,
                   tag_key=self.tag_key,
                   debug_key="DEBUG")
     sink = blocks.vector_sink_b()
     strm2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, self.tag_key)
     # Connect
     self.tb.connect(source, sink)
     self.tb.connect(source, strm2pdu)
     self.tb.msg_connect(strm2pdu, "pdus", source, "trigger")
     # Confirm
     self.tb.start()
     cycles = 0
     while source.ntriggers < 3 and cycles < 50:
         time.sleep(0.1)
         cycles += 1
     self.tb.stop()
     self.tb.wait()
     ntrigs = source.ntriggers
     result = sink.data()
     self.assertGreater(ntrigs, 2,
                        "Insufficient number of triggers {}".format(ntrigs))
     for i, r in enumerate(result):
         self.assertEqual(r, bits[i % len(bits)],
                          "Incorrect data out at index {}".format(i))
コード例 #15
0
 def test_001_t(self):
     pkt_tag = gr.tag_t()
     pkt_tag.key = pmt.intern("pkt")
     mod_types = ('BPSK', 'QPSK', '8PSK', 'QAM16', 'QAM64')
     for mod_type in mod_types:
         print("Testing {}...".format(mod_type))
         modulator = modulator_classic(mod_type)
         demodulator = demodulator_classic(mod_type, 200)
         src_data = get_random_bits(1000 * modulator.bits_per_symbol)
         pkt_tag.value = pmt.to_pmt(len(src_data))
         src = blocks.vector_source_b(src_data, False, 1, [pkt_tag])
         snk = blocks.vector_sink_b()
         tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt")
         pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt")
         self.tb.connect(src, tag2pdu)
         self.tb.msg_connect(tag2pdu, "pdus", modulator, "bits")
         self.tb.msg_connect(modulator, "symbols", demodulator, "symbols")
         self.tb.msg_connect(demodulator, "bits", pdu2tag, "pdus")
         self.tb.connect(pdu2tag, snk)
         self.tb.start()
         # check data
         while demodulator.packet_cnt < 1:
             time.sleep(0.1)
         self.tb.stop()
         self.tb.wait()
         result_data = snk.data()
         for i in range(1000 * modulator.bits_per_symbol):
             self.assertEqual(src_data[i], result_data[i])
コード例 #16
0
    def __init__(self,
                 host='127.0.0.1',
                 iq_port='9094',
                 packet_port='9095',
                 sample_filename='sample_filename.dat'):
        gr.top_block.__init__(self, "Hurdle 1 Solution Stub")

        ##################################################
        # Parameters
        ##################################################
        self.host = host
        self.iq_port = iq_port
        self.packet_port = packet_port
        self.sample_filename = sample_filename

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4e6
        self.num_garbage = num_garbage = int(1e6 / 8)

        ##################################################
        # Blocks
        ##################################################
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1,
                                                 samp_rate / 8.0, True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 1000, 'packet_len')
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_CLIENT", host,
                                                       packet_port, 10000,
                                                       False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", host,
                                                     iq_port, 10000, False)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, num_garbage)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1,
                                                   sample_filename, False)
        self.blocks_file_sink_0.set_unbuffered(False)
        self.analog_random_source_x_0 = blocks.vector_source_b(
            map(int, numpy.random.randint(0, 255, 1000)), True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.blocks_socket_pdu_0_0, 'pdus'))
        self.connect((self.analog_random_source_x_0, 0),
                     (self.blocks_throttle_1, 0))
        self.connect((self.blocks_head_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_throttle_1, 0), (self.blocks_head_0, 0))
コード例 #17
0
 def test_002_tags_plus_data(self):
     packet_len = 16
     src_data = range(packet_len)
     tag1 = gr.tag_t()
     tag1.offset = 0
     tag1.key = pmt.string_to_symbol('spam')
     tag1.value = pmt.from_long(23)
     tag2 = gr.tag_t()
     tag2.offset = 10  # Must be < packet_len
     tag2.key = pmt.string_to_symbol('eggs')
     tag2.value = pmt.from_long(42)
     src = blocks.vector_source_f(src_data, tags=(tag1, tag2))
     s2ts = blocks.stream_to_tagged_stream(gr.sizeof_float,
                                           vlen=1,
                                           packet_len=packet_len,
                                           len_tag_key="packet_len")
     ts2pdu = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
     dbg = blocks.message_debug()
     self.tb.connect(src, s2ts, ts2pdu)
     self.tb.msg_connect(ts2pdu, "pdus", dbg, "store")
     self.tb.start()
     self.tb.wait()
     result_msg = dbg.get_message(0)
     metadata = pmt.to_python(pmt.car(result_msg))
     vector = pmt.f32vector_elements(pmt.cdr(result_msg))
     self.assertEqual(metadata, {'eggs': 42, 'spam': 23})
     self.assertFloatTuplesAlmostEqual(tuple(vector), src_data)
コード例 #18
0
ファイル: qa_socket_pdu.py プロジェクト: dl1ksv/gnuradio
    def test_003 (self):
        # Test that block stops when interacting with streaming interface
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x73, 0x75, 0x63, 0x68, 0x74, 0x65, 0x73, 0x74, 0x76, 0x65, 0x72, 0x79, 0x70, 0x61, 0x73, 0x73)
        tag_dict = {"offset": 0}
        tag_dict["key"] = pmt.intern("len")
        tag_dict["value"] = pmt.from_long(8)
        tag1 = gr.python_to_tag(tag_dict)
        tag_dict["offset"] = 8
        tag2 = gr.python_to_tag(tag_dict)
        tags = [tag1, tag2]

        src = blocks.vector_source_b(srcdata, False, 1, tags)
        ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len")
        pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141")
        #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len")
        head = blocks.head(gr.sizeof_char, 10)
        sink = blocks.vector_sink_b(1)

        self.tb.connect(src, ts_to_pdu)
        self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus")
        # a UDP socket connects pdu_send to pdu_recv
        # TODO: test that the recv socket can be destroyed from downstream
        # that signals DONE. Also that we get the PDUs we sent
        #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus")
        #self.tb.connect(pdu_to_ts, head, sink)
        self.tb.run()
コード例 #19
0
ファイル: qa_pdu.py プロジェクト: Appiah/gnuradio
 def test_002_tags_plus_data(self):
     packet_len = 16
     src_data = range(packet_len)
     tag1 = gr.tag_t()
     tag1.offset = 0
     tag1.key = pmt.string_to_symbol('spam')
     tag1.value = pmt.from_long(23)
     tag2 = gr.tag_t()
     tag2.offset = 10 # Must be < packet_len
     tag2.key = pmt.string_to_symbol('eggs')
     tag2.value = pmt.from_long(42)
     src = blocks.vector_source_f(src_data, tags=(tag1, tag2))
     s2ts = blocks.stream_to_tagged_stream(gr.sizeof_float, vlen=1, packet_len=packet_len, len_tag_key="packet_len")
     ts2pdu = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
     dbg = blocks.message_debug()
     self.tb.connect(src, s2ts, ts2pdu)
     self.tb.msg_connect(ts2pdu, "pdus", dbg, "store")
     self.tb.start()
     while dbg.num_messages() < 1:
         time.sleep(0.1)
     self.tb.stop()
     self.tb.wait()
     result_msg = dbg.get_message(0)
     metadata = pmt.to_python(pmt.car(result_msg))
     vector   = pmt.f32vector_elements(pmt.cdr(result_msg))
     self.assertEqual(metadata, {'eggs': 42, 'spam': 23})
     self.assertFloatTuplesAlmostEqual(tuple(vector), src_data)
コード例 #20
0
    def test_000(self):
        # Just run some data through and make sure it doesn't puke.
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

        src = blocks.pdu_to_tagged_stream(blocks.byte_t)
        snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t)
        snk2 = blocks.vector_sink_b()
        snk = blocks.tag_debug(1, "test")
        snk.set_display(False)

        dbg = blocks.message_debug()

        # Test that the right number of ports exist.
        pi = snk3.message_ports_in()
        po = snk3.message_ports_out()
        # system port is defined automatically
        self.assertEqual(pmt.length(pi), 1)
        self.assertEqual(pmt.length(po), 1)

        self.tb.connect(src, snk)
        self.tb.connect(src, snk2)
        self.tb.connect(src, snk3)
        self.tb.msg_connect(snk3, "pdus", dbg, "store")

        # make our reference and message pmts
        port = pmt.intern("pdus")
        msg = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF))

        # post the message
        src.to_basic_block()._post(port, msg)
        src.to_basic_block()._post(
            pmt.intern("system"), pmt.cons(pmt.intern("done"),
                                           pmt.from_long(1)))

        self.tb.start()
        self.tb.wait()

        # Get the vector of data from the vector sink
        result_data = snk2.data()

        # Get the vector of data from the message sink
        # Convert the message PMT as a pair into its vector
        result_msg = dbg.get_message(0)
        msg_vec = pmt.cdr(result_msg)
        # pmt.print(msg_vec)

        # Convert the PMT vector into a Python list
        msg_data = []
        for i in range(16):
            msg_data.append(pmt.u8vector_ref(msg_vec, i))

        actual_data = 16 * [
            0xFF,
        ]
        self.assertEqual(actual_data, list(result_data))
        self.assertEqual(actual_data, msg_data)
コード例 #21
0
    def __init__(self, bb_params, tcp_addr):
        gr.hier_block2.__init__(
            self,
            "Build and Send Pkt",
            gr.io_signature(1, 1, gr.sizeof_char * 1),  # single in
            gr.io_signature(0, 0, 0)  # output via zmq
        )

        # parameters
        self.bb_params = bb_params
        self.tcp_addr = tcp_addr

        # variables
        self.tag_name = "packet_len"
        self.preamble_str = ""
        for bit in self.bb_params.preamble:
            if bit == 1:
                self.preamble_str = self.preamble_str + '1'
            else:
                self.preamble_str = self.preamble_str + '0'

        # blocks
        # detect and tag any preambles
        self.digital_correlate_access_code_xx_ts_0 = \
            digital.correlate_access_code_bb_ts(
                self.preamble_str,
                0,
                self.tag_name)
        self.connect((self, 0),
                     (self.digital_correlate_access_code_xx_ts_0, 0))

        # pack the bits into bytes
        self.blocks_repack_bits_bb_0 = \
            blocks.repack_bits_bb(
                1,
                8,
                self.tag_name,
                False,
                gr.GR_MSB_FIRST)
        self.connect((self.digital_correlate_access_code_xx_ts_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))

        # convert payloads to PDUs
        self.blocks_tagged_stream_to_pdu_0 = \
            blocks.tagged_stream_to_pdu(blocks.byte_t, self.tag_name)
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))

        # send PDU to zmq sink
        self.zeromq_push_msg_sink_0 = \
            zeromq.push_msg_sink(
                self.tcp_addr,
                100)
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.zeromq_push_msg_sink_0, 'in'))
コード例 #22
0
ファイル: qa_pdu.py プロジェクト: ArtemPisarenko/gnuradio
    def test_000(self):
        # Just run some data through and make sure it doesn't puke.
        src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

        src = blocks.pdu_to_tagged_stream(blocks.byte_t)
        snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t)
        snk2 = blocks.vector_sink_b()
        snk = blocks.tag_debug(1, "test")
        snk.set_display(False)

        dbg = blocks.message_debug()

        # Test that the right number of ports exist.
        pi = snk3.message_ports_in()
        po = snk3.message_ports_out()
        self.assertEqual(pmt.length(pi), 0)
        self.assertEqual(pmt.length(po), 1)

        self.tb.connect(src, snk)
        self.tb.connect(src, snk2)
        self.tb.connect(src, snk3)
        self.tb.msg_connect(snk3, "pdus", dbg, "store")
        self.tb.start()

        # make our reference and message pmts
        port = pmt.intern("pdus")
        msg = pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF))

        # post the message
        src.to_basic_block()._post(port, msg) # eww, what's that smell?

        while dbg.num_messages() < 1:
            time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        # Get the vector of data from the vector sink
        result_data = snk2.data()

        # Get the vector of data from the message sink
        # Convert the message PMT as a pair into its vector
        result_msg = dbg.get_message(0)
        msg_vec = pmt.cdr(result_msg)
        #pmt.print(msg_vec)

        # Convert the PMT vector into a Python list
        msg_data = []
        for i in xrange(16):
            msg_data.append(pmt.u8vector_ref(msg_vec, i))

        actual_data = 16*[0xFF,]
        self.assertEqual(actual_data, list(result_data))
        self.assertEqual(actual_data, msg_data)
コード例 #23
0
    def __init__(self):
        gr.top_block.__init__(self, "Ask Tx Top Raspi")

        ##################################################
        # Variables
        ##################################################
        self.sound_card_sample_rate = sound_card_sample_rate = 44000
        self.samples_per_symbol = samples_per_symbol = 19
        self.symbol_rate = symbol_rate = sound_card_sample_rate / samples_per_symbol
        self.bits_per_symbol = bits_per_symbol = 1

        self.variable_rrc_filter_taps = variable_rrc_filter_taps = firdes.root_raised_cosine(
            15, sound_card_sample_rate, symbol_rate, 0.5, 70)

        self.bit_rate = bit_rate = symbol_rate / bits_per_symbol

        ##################################################
        # Blocks
        ##################################################
        self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(
            samples_per_symbol, (variable_rrc_filter_taps))
        self.interp_fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_hdlc_framer_pb_0 = digital.hdlc_framer_pb('packet_len')
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bf(
            ([-1, 1]), 1)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, bit_rate,
                                                 True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.byte_t, 'packet_len')
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(
            gr.sizeof_char, 1, 32, "packet_len")
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1,
                                                       './test_src_file.txt',
                                                       True)
        self.audio_sink_0 = audio.sink(int(sound_card_sample_rate), '', True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.digital_hdlc_framer_pb_0, 'in'))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_1, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_throttle_1, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.interp_fir_filter_xxx_0, 0))
        self.connect((self.digital_hdlc_framer_pb_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.interp_fir_filter_xxx_0, 0), (self.audio_sink_0, 0))
コード例 #24
0
    def __init__(self, syncword_threshold=None, options=None):
        gr.hier_block2.__init__(self, 'aausat4_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.deframer = sync_to_pdu_soft(packlen=1996 + 8,
                                         sync=_syncword,
                                         threshold=syncword_threshold)
        self.fsm = aausat4_remove_fsm()
        self.viterbi_short = fec.cc_decoder.make(1020, 7, 2, [79, -109], 0, -1,
                                                 fec.CC_TERMINATED, False)
        self.viterbi_decoder_short = fec.async_decoder(self.viterbi_short,
                                                       True, False, 1020 // 8)
        self.viterbi_long = fec.cc_decoder.make(1996, 7, 2, [79, -109], 0, -1,
                                                fec.CC_TERMINATED, False)
        self.viterbi_decoder_long = fec.async_decoder(self.viterbi_long, False,
                                                      False, 1996 // 8)

        # Workaround for bug https://github.com/gnuradio/gnuradio/pull/2965
        # We use packed output for Viterbi short decoder and then
        # we unpack the PDUs.
        self.pdu2tag = blocks.pdu_to_tagged_stream(byte_t, 'packet_len')
        self.unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.taglength = blocks.tagged_stream_multiply_length(
            gr.sizeof_char * 1, 'packet_len', 8)
        self.tag2pdu = blocks.tagged_stream_to_pdu(byte_t, 'packet_len')

        self.scrambler = ccsds_descrambler()
        self.rs = decode_rs(False, 1)

        self.connect(self, self.deframer)
        self.msg_connect((self.deframer, 'out'), (self.fsm, 'in'))
        self.msg_connect((self.fsm, 'short'),
                         (self.viterbi_decoder_short, 'in'))
        self.msg_connect((self.fsm, 'long'), (self.viterbi_decoder_long, 'in'))

        # Workaround
        self.msg_connect((self.viterbi_decoder_short, 'out'),
                         (self.pdu2tag, 'pdus'))
        self.connect(self.pdu2tag, self.unpack, self.taglength, self.tag2pdu)
        self.msg_connect((self.tag2pdu, 'pdus'), (self.scrambler, 'in'))

        self.msg_connect((self.viterbi_decoder_long, 'out'),
                         (self.scrambler, 'in'))
        self.msg_connect((self.scrambler, 'out'), (self.rs, 'in'))
        self.msg_connect((self.rs, 'out'), (self, 'out'))
コード例 #25
0
    def __init__(self, frameTag="packet_len", numRevs=20):
        gr.hier_block2.__init__(
            self,
            "AX.25 Packet Formatter",
            gr.io_signature(0, 0, 0),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_in("in")
        self.message_port_register_hier_out("out")

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

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

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.amateur_AX25_Packet_Encoder_0, 'pkt'),
                         (self.digital_hdlc_framer_pb_0, 'in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self, 'out'))
        self.msg_connect((self, 'in'),
                         (self.amateur_AX25_Packet_Encoder_0, 'data'))
        self.connect((self.amateur_Tagged_Nrzi_Encoder_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0),
                     (self.blocks_tagged_stream_mux_0, 0))
        self.connect((self.blocks_tagged_stream_mux_0, 0),
                     (self.amateur_Tagged_Nrzi_Encoder_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.digital_hdlc_framer_pb_0, 0),
                     (self.blocks_tagged_stream_mux_0, 1))
コード例 #26
0
ファイル: chat_ofdm_rx.py プロジェクト: mbr0wn/gr-fosdem
    def __init__(self):
        gr.top_block.__init__(self, "OFDMChatAppRx")

        ##################################################
        # Variables
        ##################################################
        self.tune_offset = tune_offset = 500e3
        self.samp_rate = samp_rate = 500000
        self.len_tag_key = len_tag_key = "packet_len"
        self.fft_len = fft_len = 128
        self.decimation = decimation = 4

        ##################################################
        # Blocks
        ##################################################
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
        self.osmosdr_source_0.set_sample_rate(samp_rate*decimation)
        self.osmosdr_source_0.set_center_freq(400e6-tune_offset, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(0, 0)
        self.osmosdr_source_0.set_iq_balance_mode(0, 0)
        self.osmosdr_source_0.set_gain_mode(0, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
                decimation,
                (filter.firdes.low_pass(1.0, samp_rate*decimation, 300e3, 100e3)),
                tune_offset,
                samp_rate*decimation
        )
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+"rx_len",
        	  packet_length_tag_key="rx_len",
        	  bps_header=1,
        	  bps_payload=2,
        	  debug_log=False,
        	  scramble_bits=True
         )
        self.tagged_stream_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'rx_len')
        self.pdu_receiver = fosdem.pdu_receiver()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.osmosdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_ofdm_rx_0, 0), self.tagged_stream_to_pdu)
        self.msg_connect(self.tagged_stream_to_pdu, "pdus", self.pdu_receiver, "pdus")
コード例 #27
0
    def __init__(self,
                 packlen=0,
                 sync='00011010110011111111110000011101',
                 threshold=4):
        gr.hier_block2.__init__(
            self,
            'Sync and create packed PDU',
            gr.io_signature(1, 1, gr.sizeof_char * 1),
            gr.io_signature(0, 0, 0),
        )
        self.message_port_register_hier_out('out')

        ##################################################
        # Parameters
        ##################################################
        self.packlen = packlen
        self.sync = sync
        self.threshold = threshold

        ##################################################
        # Blocks
        ##################################################
        self.satellites_fixedlen_tagger_0_0_0 = (satellites.fixedlen_tagger(
            'syncword', 'packet_len', packlen * 8, numpy.byte))
        self.digital_correlate_access_code_tag_bb_0_0_0 = (
            digital.correlate_access_code_tag_bb(sync, threshold, 'syncword'))
        self.blocks_unpacked_to_packed_xx_0 = (blocks.unpacked_to_packed_bb(
            1, gr.GR_MSB_FIRST))
        self.blocks_tagged_stream_to_pdu_0_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 / 8.0))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0, 'pdus'),
                         (self, 'out'))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_0_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.digital_correlate_access_code_tag_bb_0_0_0, 0),
                     (self.satellites_fixedlen_tagger_0_0_0, 0))
        self.connect((self, 0),
                     (self.digital_correlate_access_code_tag_bb_0_0_0, 0))
        self.connect((self.satellites_fixedlen_tagger_0_0_0, 0),
                     (self.blocks_unpacked_to_packed_xx_0, 0))
コード例 #28
0
    def test_001_t(self):
        # set up fg
        src1 = analog.sig_source_c(512, analog.GR_COS_WAVE, 128, 0.5, 0)
        op1 = blocks.head(gr.sizeof_gr_complex, 128)
        op2 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, 1,
                                             "packet_len")
        op3 = blocks.tagged_stream_to_pdu(blocks.complex_t, "packet_len")
        dst = blocks.vector_sink_c(1)

        DUT = hydra.hydra_async_sink(1, 64, 100e3, 200e3, ((100e3, 200e3), ))

        self.tb.msg_connect((op3, 'pdus'), (DUT, 'vr0'))
        self.tb.connect(src1, op1, op2, op3)
        self.tb.connect(DUT, dst)
        self.tb.run()
コード例 #29
0
    def __init__(self):
        gr.top_block.__init__(self, "ZMQ RX Test")

        ##################################################
        # Variables
        ##################################################
        self.tcp_addr_msg_out = zmu.TCP_RX_XFIL
        self.samp_rate = samp_rate = 1e3
        self.preamble = (85, 85, 0, 6, 0, 6, 80, 73, 80, 73, 70, 90, 0, 0, 0,
                         0, 0, 0, 0)

        ##################################################
        # Blocks
        ##################################################
        self.zeromq_push_msg_sink_0 = \
            zeromq.push_msg_sink(self.tcp_addr_msg_out, 100)
        self.digital_correlate_access_code_xx_ts_0 = \
            digital.correlate_access_code_bb_ts(
                '0101010101010101',
                0,
                'packet_len')
        self.blocks_vector_source_x_0 = \
            blocks.vector_source_b(
                self.preamble, True, 1, [])
        self.blocks_throttle_0 = \
            blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_tagged_stream_to_pdu_0 = \
            blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.blocks_repack_bits_bb_0 = \
            blocks.repack_bits_bb(1, 8, 'packet_len', False, gr.GR_MSB_FIRST)
        self.blocks_packed_to_unpacked_xx_0 = \
            blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.zeromq_push_msg_sink_0, 'in'))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_correlate_access_code_xx_ts_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.digital_correlate_access_code_xx_ts_0, 0),
                     (self.blocks_repack_bits_bb_0, 0))
コード例 #30
0
    def __init__(self):
        gr.top_block.__init__(self, "Ber Test")

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.nfilts = nfilts = 32
        self.timing_loop_bw = timing_loop_bw = 62.8e-3
        self.samp_rate = samp_rate = 32000
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts)
        self.qpsk = qpsk = digital.constellation_rect(([1+1j, -1+1j, -1-1j, 1-1j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base()
        self.excess_bw = excess_bw = 0.35

        ##################################################
        # Blocks
        ##################################################
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1)
        self.digital_constellation_modulator_0 = digital.generic_mod(
          constellation=qpsk,
          differential=False,
          samples_per_symbol=sps,
          pre_diff_code=True,
          excess_bw=excess_bw,
          verbose=True,
          log=False,
          )
        self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(qpsk)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb(2, 8, "", False, gr.GR_LSB_FIRST)
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 2, "", False, gr.GR_LSB_FIRST)
        self.blocks_random_pdu_0 = blocks.random_pdu(5, 6, chr(0xFF), 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.PMT_T, 2000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0, 'generate'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repack_bits_bb_0, 0))
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0))
        self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_repack_bits_bb_0_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0))
コード例 #31
0
    def __init__(self, callback):
        gr.hier_block2.__init__(self, "payload_sink_pdu",
                                gr.io_signature(1, 1, gr.sizeof_char * 1),
                                gr.io_signature(0, 0, 0))
        self.callback = callback
        #blocks
        self.tagged_stream_to_pdu = blocks.tagged_stream_to_pdu(
            blocks.byte_t, "packet_len")
        self.check_crc = digital.crc32_async_bb(True)
        self.msg_sink = ofdm_cr_tools.message_handler(self.callback)

        # Connections
        self.connect(self, self.tagged_stream_to_pdu)
        self.msg_connect((self.tagged_stream_to_pdu, 'pdus'),
                         (self.check_crc, 'in'))
        self.msg_connect((self.check_crc, 'out'), (self.msg_sink, 'in'))
コード例 #32
0
 def setUp(self):
     self.tb = gr.top_block()
     self.nfreq_samps = 256
     self.freqs = [11. / 256, 41. / 256, 93. / 256]
     self.corr_reps = 4
     self.channel = channels.channel_model(
         noise_voltage=0.01,
         frequency_offset=1e-5,
         epsilon=1.0,
         taps=[0.8, 0.1, 0.05, 0.01, 0.01, 0.005])
     self.channel_in = blocks.pdu_to_tagged_stream(blocks.complex_t,
                                                   "frame")
     self.channel_out = blocks.tagged_stream_to_pdu(blocks.complex_t,
                                                    "frame")
     self.tb.connect(self.channel_in, self.channel)
     self.tb.connect(self.channel, self.channel_out)
コード例 #33
0
 def test_001_t (self):
     # set up fg
     self.src = blocks.vector_source_b(range(12), False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 4, "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.zeropadding = ieee802_15_4.zeropadding_b(2)
     self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.zeropadding, "in")
     self.tb.connect(self.zeropadding, self.snk)
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     # check data
     data = self.snk.data()
     self.assertFloatTuplesAlmostEqual(data, (0,1,2,3,0,0,4,5,6,7,0,0,8,9,10,11,0,0))
コード例 #34
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))
コード例 #35
0
    def run_with_frame_len(self, frame_len):
        self.tb = gr.top_block()
        noise = analog.noise_source_f(analog.GR_GAUSSIAN, 1, 0)
        head = blocks.head(gr.sizeof_float, self.n_frames * frame_len)
        tag = blocks.stream_to_tagged_stream(gr.sizeof_float, 1, frame_len, "packet_len")
        stream2pdu = blocks.tagged_stream_to_pdu(blocks.float_t, 'packet_len')
        
        viterbi = fec.cc_decoder.make(frame_len//2, 7, 2, [79,-109], 0, -1, fec.CC_TERMINATED, False)
        cc_decoder = fec.async_decoder(viterbi, False, False, frame_len)
        
        self.tb.connect(noise, head, tag, stream2pdu)
        self.tb.msg_connect((stream2pdu, 'pdus'), (cc_decoder, 'in'))
        
        self.tb.run()
        # the test is considered successful if it hasn't segfaulted or aborted

        self.tb = None
コード例 #36
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'))
コード例 #37
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))
コード例 #38
0
 def test_001_t(self):
     # set up fg
     self.src = blocks.vector_source_b(range(12), False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 4,
                                                "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.zeropadding = ieee802_15_4.zeropadding_b(2)
     self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.zeropadding, "in")
     self.tb.connect(self.zeropadding, self.snk)
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     # check data
     data = self.snk.data()
     self.assertFloatTuplesAlmostEqual(
         data, (0, 1, 2, 3, 0, 0, 4, 5, 6, 7, 0, 0, 8, 9, 10, 11, 0, 0))
コード例 #39
0
ファイル: qa_hash.py プロジェクト: risteon/gr-openssl
    def test_001_t (self):
        hash_func = "md5"
        text = bytearray("ABCDEFGH")
        exp_result = bytearray(["\x47","\x83","\xe7","\x84","\xb4","\xfa","\x2f","\xba","\x9e","\x4d","\x65","\x02","\xdb","\xc6","\x4f","\x8f"])

        src = blocks.vector_source_b(text)
        stts = blocks.stream_to_tagged_stream(1, 1, 8, "packet_len")
        tstpdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        hash_block = crypto.hash(hash_func)
        snk = blocks.message_debug()

        self.tb.connect(src, stts, tstpdu);
        self.tb.msg_connect(tstpdu, "pdus", hash_block, "pdus")
        self.tb.msg_connect(hash_block, "pdus", snk, "store")

        self.tb.run()

        hash = bytearray(pmt.u8vector_elements(pmt.cdr((snk.get_message(0)))))
        self.assertEqual(exp_result, hash)
コード例 #40
0
ファイル: tun_source_test.py プロジェクト: orca-leo/2016s-SEP
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="tun_source Test")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Blocks
        ##################################################
        self.orcatun_tun_source_b_0 = orcatun.tun_source_b("tun3", "packet_len", True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char*1, "tun_source_debug", ""); self.blocks_tag_debug_0.set_display(True)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.orcatun_tun_source_b_0, 0), (self.blocks_tag_debug_0, 0))    
        self.connect((self.orcatun_tun_source_b_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
コード例 #41
0
 def test_001_t (self):
     # set up fg
     phr = np.zeros((12,),dtype=int)
     data1 = np.array([7, 128], dtype=int)
     data2 = np.array([8, 129], dtype=int)
     data1_unp = np.unpackbits(np.array(data1,dtype=np.uint8))
     data2_unp = np.unpackbits(np.array(data2,dtype=np.uint8))
     data_in = np.concatenate((phr, data1_unp, phr, data2_unp))
     # blob = pmt.make_blob(data_in, len(data_in))
     self.src = blocks.vector_source_b(data_in, False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 2*8+len(phr), "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.phr_removal = ieee802_15_4.phr_removal(phr)
     self.msg_sink = blocks.message_debug()
     # self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
     # self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.phr_removal, "in")
     self.tb.msg_connect(self.phr_removal, "out", self.msg_sink, "store")
     # self.tb.msg_connect(self.phr_removal, "out", self.pdu2ts, "pdus")
     # self.tb.connect(self.pdu2ts, self.snk)
     self.tb.start()
     time.sleep(0.5)
     self.tb.stop()
     num_msgs = self.msg_sink.num_messages()
     self.assertTrue(num_msgs == 2)
     data_out = []
     for i in range(num_msgs):
         tmp = pmt.to_python(self.msg_sink.get_message(i))
         data_out = np.concatenate((data_out, tmp[1]))
     # check data
     # data_out = self.snk.data()
     # print "input:"
     # for i in data:
     # 	print i
     # print "output:"
     # for i in data_out:
     # 	print data_out
     ref = np.concatenate((data1,data2))
     print "ref:", ref
     # print "data_out:", data_out
     self.assertFloatTuplesAlmostEqual(data_out, ref)
コード例 #42
0
 def test_004_t (self):
 	# PDU size < fragmentation size, overlap
     # set up fg
     self.src = blocks.vector_source_b(range(255), False, 1, [])
     self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 4, "packet_len")
     self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
     self.frag = ieee802_15_4.fragmentation(6)
     self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
     self.snk = blocks.vector_sink_b(1)
     self.tb.connect(self.src, self.s2ts, self.ts2pdu)
     self.tb.msg_connect(self.ts2pdu, "pdus", self.frag, "in")
     self.tb.msg_connect(self.frag, "out", self.pdu2ts, "pdus")
     self.tb.connect(self.pdu2ts, self.snk)
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     # check data
     data = [i for i in self.snk.data()]
     print data
     self.assertTrue(data==range(252))
コード例 #43
0
ファイル: tw_1.py プロジェクト: daniestevez/gr-ax100
    def __init__(self):
        gr.top_block.__init__(self, "TW-1 test decoder")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 48000
        self.samp_per_sym = samp_per_sym = 10
        self.gain_mu = gain_mu = 0.175*3

        ##################################################
        # Blocks
        ##################################################
        self.synctags_fixedlen_tagger_0 = synctags.fixedlen_tagger("syncword", "packet_len", 256*8, numpy.byte)
        self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate, 2400, 2000, firdes.WIN_HAMMING, 6.76))
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16)
        self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10010011000010110101000111011110", 4, "syncword")
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(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.blocks_wavfile_source_0 = blocks.wavfile_source("/tmp/tw-1c.wav", False)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST)
        self.blocks_tagged_stream_to_pdu_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/8.0)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.blocks_message_debug_1, 'print_pdu'))    
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.ax100_gomx3_rs_decode_0, 'in'))    
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))    
        self.connect((self.blocks_wavfile_source_0, 0), (self.low_pass_filter_0, 0))    
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0))    
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))    
        self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.synctags_fixedlen_tagger_0, 0))    
        self.connect((self.digital_descrambler_bb_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0))    
        self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))    
        self.connect((self.synctags_fixedlen_tagger_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))    
コード例 #44
0
ファイル: fifo_async_source.py プロジェクト: pjbalt/satellite
    def __init__(self, fifo_file, poling_rate, pkt_size):
        gr.hier_block2.__init__(self,
            "fifo_async_source",
            gr.io_signature(0,0,0),  # Input signature
            gr.io_signature(0,0,0)) # Output signature

        self.message_port_register_hier_out("async_pdu")

        ##################################################
        # Blocks
        ##################################################
        self.mods_file_source_nonblock_0 = mods.file_source_nonblock(fifo_file, poling_rate)
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, pkt_size, "packet_len")
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')

        ##################################################
        # Connections
        ##################################################
        self.connect((self.mods_file_source_nonblock_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self,"async_pdu"))    
コード例 #45
0
    def __init__(self):
        gr.top_block.__init__(self, "Tun Sink Pdu Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Tun Sink Pdu Test")
        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", "tun_sink_pdu_test")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Blocks
        ##################################################
        self.blocks_vector_source_x_0 = blocks.vector_source_b((193,  73,  64,   0,  17, 163,  94,   5,  57,   0,  13,  94, 119, 116, 101, 115, 116,  10), False, 1, [])
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 18, "packet_len")
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))    
コード例 #46
0
ファイル: ofdm_transceiver.py プロジェクト: jLantxa/spectrum
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM Transceiver")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        self._lock = threading.RLock()

        ##################################################
        # Variables
        ##################################################
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.packet_length_tag_key = packet_length_tag_key = "packet_len"
        self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)
        self.length_tag_key = length_tag_key = "frame_len"
        self.header_mod = header_mod = digital.constellation_bpsk()
        self.fft_len = fft_len = 64
        self.waterfall_min = waterfall_min = -140
        self.waterfall_max = waterfall_max = -20
        self.tx_gain = tx_gain = 0.01
        self.th = th = 10**(-40/10)
        self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j]
        self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.]
        self.size = size = 256
        self.samp_rate = samp_rate = 2e6
        self.period = period = 10
        self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1)
        self.nsamples = nsamples = 1000
        self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False)
        self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols)
        self.center_freq = center_freq = 2.412e9

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, "Spectrum")
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, "Settings")
        self.top_layout.addWidget(self.tab)
        self._waterfall_min_range = Range(-200, -50, 1, -140, 200)
        self._waterfall_min_win = RangeWidget(self._waterfall_min_range, self.set_waterfall_min, "Waterfall Min", "counter_slider", float)
        self.tab_layout_1.addWidget(self._waterfall_min_win)
        self._waterfall_max_range = Range(-50, 0, 1, -20, 200)
        self._waterfall_max_win = RangeWidget(self._waterfall_max_range, self.set_waterfall_max, "Waterfall Max", "counter_slider", float)
        self.tab_layout_1.addWidget(self._waterfall_max_win)
        self._samp_rate_options = [1.5e6, 2e6, 4e6, 5e6, 10e6, 20e6 ]
        self._samp_rate_labels = ["1.5 MHz", "2 MHz", "4 MHz", "5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate [MHz]"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.tab_layout_0.addWidget(self._samp_rate_tool_bar)
        self._center_freq_options = [868e6, 2.412e9, 2.417e9, 2.422e9, 2.427e9, 2.432e9, 2.437e9, 2.442e9, 2.447e9, 2.452e9, 2.457e9, 2.462e9, 2.467e9, 2.472e9]
        self._center_freq_labels = ["868M", "1",  "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",  "12", "13"]
        self._center_freq_tool_bar = Qt.QToolBar(self)
        self._center_freq_tool_bar.addWidget(Qt.QLabel("Channel"+": "))
        self._center_freq_combo_box = Qt.QComboBox()
        self._center_freq_tool_bar.addWidget(self._center_freq_combo_box)
        for label in self._center_freq_labels: self._center_freq_combo_box.addItem(label)
        self._center_freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._center_freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._center_freq_options.index(i)))
        self._center_freq_callback(self.center_freq)
        self._center_freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_center_freq(self._center_freq_options[i]))
        self.top_layout.addWidget(self._center_freq_tool_bar)
        self._tx_gain_range = Range(0, 1, 0.001, 0.01, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain, "TX Gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._th_range = Range(10**(-80/10), 10**(-10/10), 0.0001, 10**(-40/10), 200)
        self._th_win = RangeWidget(self._th_range, self.set_th, "Threshold", "counter_slider", float)
        self.tab_layout_0.addWidget(self._th_win)
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	center_freq, #fc
        	samp_rate, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.01)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(False)
        
        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()
        
        if complex == type(float()):
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)
        
        labels = ["", "", "", "", "",
                  "", "", "", "", ""]
        colors = [5, 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_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])
        
        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(waterfall_min, waterfall_max)
        
        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_0_win)
        self._period_range = Range(1, 10000, 1, 10, 200)
        self._period_win = RangeWidget(self._period_range, self.set_period, "Period", "counter_slider", float)
        self.tab_layout_1.addWidget(self._period_win)
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=64, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+packet_length_tag_key,
        	  packet_length_tag_key=packet_length_tag_key,
        	  occupied_carriers=occupied_carriers,
        	  pilot_carriers=pilot_carriers,
        	  pilot_symbols=pilot_symbols,
        	  sync_word1=sync_word1,
        	  sync_word2=sync_word2,
        	  bps_header=1,
        	  bps_payload=1,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(128, True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, packet_length_tag_key)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))    
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))    
コード例 #47
0
ファイル: top_block.py プロジェクト: michelbarbeau/gr-splash
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.k = k = 7
        self.samp_rate = samp_rate = 48000
        
        
        self.enc_cc = enc_cc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False)
            
        
        
        self.dec_cc = dec_cc = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False)
            

        ##################################################
        # Blocks
        ##################################################
        self.splash_packet_encoder_0 = splash.packet_encoder(
                  samples_per_symbol=8,
                  bits_per_symbol=1,
                  preamble="",
                  access_code="",
                  pad_for_usrp=False,
        	  payload_length=9
                )
          
        self.splash_packet_decoder_0 = splash.packet_decoder(
                  access_code="",
                  threshold=-1
                )
          
        self.splash_XCEIVER_0 = splash.XCEIVER()
        self.digital_map_bb_0 = digital.map_bb(([-1,1]))
        self.dflood_dflood_0 = dflood.dflood(
          2, 0, 30, False, False, 
          5, 65, 2, 120, 50, 2, True, None
          )
        self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
        self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "packet_len", True, gr.GR_MSB_FIRST)
        self.blocks_random_pdu_0_0 = blocks.random_pdu(1, 5, chr(0xFF), 1)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_message_strobe_2 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1)
        self.audio_source_0 = audio.source(48000, "", True)
        self.audio_sink_0 = audio.sink(48000, "", True)
        self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(-70, 1)
        self.Async_Ecnoder = fec.async_encoder(enc_cc, True, False, False, 1500)
        self.Async_Decoder = fec.async_decoder(dec_cc, True, False, 1500)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.Async_Decoder, 'out'), (self.dflood_dflood_0, 'from_radio'))    
        self.msg_connect((self.Async_Ecnoder, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0_0, 'generate'))    
        self.msg_connect((self.blocks_message_strobe_2, 'strobe'), (self.dflood_dflood_0, 'ctrl_in'))    
        self.msg_connect((self.blocks_random_pdu_0_0, 'pdus'), (self.dflood_dflood_0, 'from_app'))    
        self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'), (self.Async_Decoder, 'in'))    
        self.msg_connect((self.dflood_dflood_0, 'to_radio'), (self.Async_Ecnoder, 'in'))    
        self.msg_connect((self.dflood_dflood_0, 'to_app'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.audio_source_0, 0), (self.splash_XCEIVER_0, 0))    
        self.connect((self.blocks_char_to_float_0_1, 0), (self.blocks_tagged_stream_to_pdu_1, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.splash_packet_encoder_0, 0))    
        self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_0, 0))    
        self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0))    
        self.connect((self.splash_XCEIVER_0, 2), (self.analog_probe_avg_mag_sqrd_x_0, 0))    
        self.connect((self.splash_XCEIVER_0, 0), (self.audio_sink_0, 0))    
        self.connect((self.splash_XCEIVER_0, 1), (self.splash_packet_decoder_0, 0))    
        self.connect((self.splash_packet_decoder_0, 0), (self.blocks_repack_bits_bb_0, 0))    
        self.connect((self.splash_packet_encoder_0, 0), (self.splash_XCEIVER_0, 1))    
コード例 #48
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM Transceiver")

        self._lock = threading.RLock()

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

        ##################################################
        # Blocks
        ##################################################
        
        self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" )
        self.osmosdr_source_0.set_sample_rate(samp_rate)
        self.osmosdr_source_0.set_center_freq(center_freq, 0)
        self.osmosdr_source_0.set_freq_corr(0, 0)
        self.osmosdr_source_0.set_dc_offset_mode(1, 0)
        self.osmosdr_source_0.set_iq_balance_mode(1, 0)
        self.osmosdr_source_0.set_gain_mode(False, 0)
        self.osmosdr_source_0.set_gain(10, 0)
        self.osmosdr_source_0.set_if_gain(20, 0)
        self.osmosdr_source_0.set_bb_gain(20, 0)
        self.osmosdr_source_0.set_antenna("", 0)
        self.osmosdr_source_0.set_bandwidth(samp_rate, 0)
          
        self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" )
        self.osmosdr_sink_0.set_sample_rate(samp_rate)
        self.osmosdr_sink_0.set_center_freq(center_freq, 0)
        self.osmosdr_sink_0.set_freq_corr(10, 0)
        self.osmosdr_sink_0.set_gain(20, 0)
        self.osmosdr_sink_0.set_if_gain(20, 0)
        self.osmosdr_sink_0.set_bb_gain(0, 0)
        self.osmosdr_sink_0.set_antenna("", 0)
        self.osmosdr_sink_0.set_bandwidth(samp_rate, 0)
          
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=64, cp_len=fft_len/4,
        	  packet_length_tag_key=packet_length_tag_key,
        	  occupied_carriers=occupied_carriers,
        	  pilot_carriers=pilot_carriers,
        	  pilot_symbols=pilot_symbols,
        	  sync_word1=sync_word1,
        	  sync_word2=sync_word2,
        	  bps_header=1,
        	  bps_payload=1,
        	  rolloff=0,
        	  debug_log=True,
        	  scramble_bits=False
        	 )
        	 
        self.digital_ofdm_rx_0 = digital.ofdm_rx(
        	  fft_len=64, cp_len=fft_len/4,
        	  frame_length_tag_key='frame_'+packet_length_tag_key,
        	  packet_length_tag_key=packet_length_tag_key,
        	  occupied_carriers=occupied_carriers,
        	  pilot_carriers=pilot_carriers,
        	  pilot_symbols=pilot_symbols,
        	  sync_word1=sync_word1,
        	  sync_word2=sync_word2,
        	  bps_header=1,
        	  bps_payload=1,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, packet_length_tag_key)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, packet_length_tag_key)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((tx_gain, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.pdu_block = messaging.pdu_block(self)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.pdu_block, 'out_pdu'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))   
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.pdu_block, 'in_pdu'))      
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))    
        self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0))    
        self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))  
コード例 #49
0
ファイル: terminal_panel.py プロジェクト: zhguixin/ctl_panel
    def __init__(self,**param):
        gr.top_block.__init__(self, "Dl Recv")

        ##################################################
        # Variables
        ##################################################
        try:
            if param['Bandwidth'] == '1.4':
                self.prbl = prbl = 6
                self.fftl = fftl = 128
                self.multiply_const = multiply_const = 128.0
            else:
                self.prbl = prbl = 15
                self.fftl = fftl = 256
                self.multiply_const = multiply_const = 256.0

            if param['samp_rate_T'] == '2M':
                self.samp_rate = samp_rate = 2000000
            else:
                self.samp_rate = samp_rate = 4000000 

            self.threshold = threshold = float(param['Threshold'])
            self.gain = gain = int(param['gain_r_T'])
            self.RNTI_A = RNTI_A = int(param['RNTI_A'])
            self.sacle_0 = sacle_0 = 1024
            self.sacle = sacle = 1024
        except: print '变量初始化失败'

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            device_addr="addr=192.168.10.2",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(2.0e7, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.lte_sat_layer2_ue_0 = lte_sat.layer2_ue(RNTI_A)
        self.lte_sat_dl_subframe_demapper_0 = lte_sat.dl_subframe_demapper(RNTI_A)
        self.lte_sat_dl_baseband_sync_0 = lte_sat.dl_baseband_sync(threshold)
        self.blocks_tagged_stream_to_pdu_0_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")
        self.blocks_null_source_0 = blocks.null_source(gr.sizeof_char*1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((multiply_const, ))
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1024)
        self.audio_sink_0_0 = audio.sink(48000, "", True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_null_source_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.lte_sat_dl_subframe_demapper_0, 0), (self.lte_sat_layer2_ue_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.lte_sat_dl_baseband_sync_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0), (self.audio_sink_0_0, 0))
        self.connect((self.lte_sat_dl_baseband_sync_0, 0), (self.lte_sat_dl_subframe_demapper_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.lte_sat_dl_baseband_sync_0, "sys_info", self.lte_sat_dl_subframe_demapper_0, "sys_info")
        self.msg_connect(self.lte_sat_layer2_ue_0, "sdus", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0_0, "pdus", self.lte_sat_layer2_ue_0, "pdus")
        self.msg_connect(self.lte_sat_dl_subframe_demapper_0, "usg", self.lte_sat_layer2_ue_0, "usg")
コード例 #50
0
ファイル: BlockFactory.py プロジェクト: orca-leo/2016s-SEP
    def receiver(self):
        log = logging.getLogger('master.BlockFactory')
        t = self.vars_receive()

        ##################################################
        # Blocks - build blocks for their functionality
        ##################################################

        #FFT In Block
        if self.FFTIN:
            if self.tk_context != None:
                t.wxgui_fftsink2_0 = self.make_fftsink(self.tk_context, "FFT IN")
            else: #Set the ownership accordingly
                t.wxgui_fftsink2_0 = self.make_fftsink(t, "FFT IN")
            t.Add(t.wxgui_fftsink2_0.win)


        if self.waterfall:
            t.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c(
        	t.GetWin(),
        	baseband_freq=0,
        	dynamic_range=100,
        	ref_level=0,
        	ref_scale=2.0,
        	sample_rate=self.samp_rate,
        	fft_size=512,
        	fft_rate=15,
        	average=False,
        	avg_alpha=None,
        	title="Waterfall Plot", )
            t.Add(t.wxgui_waterfallsink2_0.win)

	t.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")

        #Tunsink
        if self.tun_handler != None:
            t.orcatun_tun_sink_pdu_0 = orcatun.tun_sink_pdu(self.tun_handler, str(self.ot))
        else: #implement tun_handler
            log.error("No TunHandler specified")
            sys.exit(1)

        #Decimator resampler
        t.rational_resampler_xxx_0_0_0_3 = self.make_resampler(1, self.interpolation_values[4] )
        t.rational_resampler_xxx_0_0_0_2 = self.make_resampler(1, self.interpolation_values[3] )
        t.rational_resampler_xxx_0_0_0_1 = self.make_resampler(1, self.interpolation_values[2] )
        t.rational_resampler_xxx_0_0_0_0 = self.make_resampler(1, self.interpolation_values[1] )
        t.rational_resampler_xxx_0_0_0 = self.make_resampler(1, self.interpolation_values[0] )

        #frame decoder
        t.orcatun_frame_decoder_0 = orcatun.frame_decoder("packet_len", self.samp_rate, self.crc)
        
        #Low pass frequence filter
        t.freq_xlating_fir_filter_xxx_0_0 = self.make_lowpassfrqfilter()

        #Complex bandpass filter
        t.fft_filter_xxx_0 = self.make_fft_filter()
        t.fft_filter_xxx_0.declare_sample_delay(0)

        #GFSK demod
        t.digital_gfsk_demod_0 = self.make_gfsk_demod()

        #Multiply constance
        t.blocks_multiply_const_vxx_0 = self.multiply_const((1, ))
        #float o complex
        t.blocks_float_to_complex_0 = self.float_to_complex(1)

        #File sinks (currently made here
        #t.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./rec.txt", False)
        #t.blocks_file_sink_0.set_unbuffered(True)
        
        #Audio source
        t.audio_source_0 = audio.source(self.samp_rate, "", True)

	#DEBUG
	t.blocks_message_debug_0 = blocks.message_debug()


        ##################################################
        # Connections - Relate blocks to each other
        ##################################################
        t.connect((t.audio_source_0, 0), (t.blocks_float_to_complex_0, 0))
        if self.waterfall:
            t.connect((t.blocks_float_to_complex_0, 0), (t.wxgui_waterfallsink2_0, 0)) 
        t.connect((t.blocks_float_to_complex_0, 0), (t.blocks_multiply_const_vxx_0, 0))    
        t.connect((t.blocks_multiply_const_vxx_0, 0), (t.fft_filter_xxx_0, 0))    
        t.connect((t.digital_gfsk_demod_0, 0), (t.orcatun_frame_decoder_0, 0))    
        t.connect((t.fft_filter_xxx_0, 0), (t.freq_xlating_fir_filter_xxx_0_0, 0))    
        t.connect((t.freq_xlating_fir_filter_xxx_0_0, 0), (t.rational_resampler_xxx_0_0_0, 0))
        if self.FFTIN:
            t.connect((t.freq_xlating_fir_filter_xxx_0_0, 0), (t.wxgui_fftsink2_0, 0))    
        #t.connect((t.orcatun_frame_decoder_0, 0), (t.blocks_file_sink_0, 0))    
        t.connect((t.orcatun_frame_decoder_0, 0), (t.blocks_tagged_stream_to_pdu_0, 0))
	t.msg_connect((t.blocks_tagged_stream_to_pdu_0, 'pdus'), (t.orcatun_tun_sink_pdu_0, 'packet'))
	t.msg_connect((t.blocks_tagged_stream_to_pdu_0, 'pdus'), (t.blocks_message_debug_0, 'print_pdu'))  
        t.connect((t.rational_resampler_xxx_0_0_0, 0), (t.rational_resampler_xxx_0_0_0_0, 0))    
        t.connect((t.rational_resampler_xxx_0_0_0_0, 0), (t.rational_resampler_xxx_0_0_0_2, 0))    
        t.connect((t.rational_resampler_xxx_0_0_0_1, 0), (t.digital_gfsk_demod_0, 0))    
        t.connect((t.rational_resampler_xxx_0_0_0_2, 0), (t.rational_resampler_xxx_0_0_0_3, 0))    
        t.connect((t.rational_resampler_xxx_0_0_0_3, 0), (t.rational_resampler_xxx_0_0_0_1, 0)) 
	
	#t.msg_connect((t.blocks_tagged_stream_to_pdu_0, 'pdus'), (t.blocks_message_debug_0, 'print'))
        return t
コード例 #51
0
    def __init__(self):
        gr.top_block.__init__(self, "Test Channel Number2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test Channel Number2")
        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", "Test_channel_Number2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Variables
        ##################################################
        self.packet_size_gige = packet_size_gige = 1024
        self.samp_rate = samp_rate = 20e6
        self.packet_size = packet_size = packet_size_gige
        self.cucala = cucala = 2.5e6
        self.RF_freq = RF_freq = 943e6

        ##################################################
        # Blocks
        ##################################################
        self.spectsensing_subband_selector_0 = spectsensing.subband_selector(40, 40)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate/1e5/40, #samp_rate
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)
        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	2048, #size
        	samp_rate/1e5, #samp_rate
        	"QT GUI Plot", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)
        self.qtgui_time_sink_x_0.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_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 2, 1)
        self.nutaq_radio420_tx_0_0.set_default_enable(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_freq(RF_freq)
        self.nutaq_radio420_tx_0_0.set_default_reference(0)
        self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0_0.set_default_calibrate(0)
        self.nutaq_radio420_tx_0_0.set_default_band(1)
        self.nutaq_radio420_tx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(1)
        self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0)
        self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_tx_0 = nutaq.radio420_tx("nutaq_carrier_perseus_TX", 1, 0)
        self.nutaq_radio420_tx_0.set_default_enable(1)
        self.nutaq_radio420_tx_0.set_default_tx_freq(RF_freq)
        self.nutaq_radio420_tx_0.set_default_reference(0)
        self.nutaq_radio420_tx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_tx_0.set_default_calibrate(0)
        self.nutaq_radio420_tx_0.set_default_band(1)
        self.nutaq_radio420_tx_0.set_default_update_rate(1)
        self.nutaq_radio420_tx_0.set_default_tx_vga1_gain(-10)
        self.nutaq_radio420_tx_0.set_default_tx_vga2_gain(15)
        self.nutaq_radio420_tx_0.set_default_tx_gain3(3)
        self.nutaq_radio420_tx_0.set_default_tx_lpf_bandwidth(1)
        self.nutaq_radio420_tx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_tx_0.set_default_tx_gain_ctrl(1)
        self.nutaq_radio420_tx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 2, 3)
        self.nutaq_radio420_rx_0_0.set_default_enable(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0_0.set_default_reference(0)
        self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0_0.set_default_calibrate(0)
        self.nutaq_radio420_rx_0_0.set_default_band(1)
        self.nutaq_radio420_rx_0_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain2(0)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain3(-8)
        self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(1)
        self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_TX", 1, 2)
        self.nutaq_radio420_rx_0.set_default_enable(1)
        self.nutaq_radio420_rx_0.set_default_rx_freq(RF_freq)
        self.nutaq_radio420_rx_0.set_default_reference(0)
        self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2)
        self.nutaq_radio420_rx_0.set_default_calibrate(0)
        self.nutaq_radio420_rx_0.set_default_band(1)
        self.nutaq_radio420_rx_0.set_default_update_rate(1)
        self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(2)
        self.nutaq_radio420_rx_0.set_default_rx_gain2(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain3(-8)
        self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2)
        self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(1)
        self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rf_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0)
        self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0)
          
        self.nutaq_custom_register_0_1_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",9)
        self.nutaq_custom_register_0_1_1.set_index(6)
        self.nutaq_custom_register_0_1_1.set_default_value(820)
        self.nutaq_custom_register_0_1_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_1_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",7)
        self.nutaq_custom_register_0_1_0.set_index(2)
        self.nutaq_custom_register_0_1_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_1 = nutaq.custom_register("nutaq_carrier_perseus_TX",6)
        self.nutaq_custom_register_0_1.set_index(0)
        self.nutaq_custom_register_0_1.set_update_rate(1)
          
        self.nutaq_custom_register_0_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",8)
        self.nutaq_custom_register_0_0_0.set_index(3)
        self.nutaq_custom_register_0_0_0.set_default_value(7)
        self.nutaq_custom_register_0_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",5)
        self.nutaq_custom_register_0_0.set_index(4)
        self.nutaq_custom_register_0_0.set_default_value(1)
        self.nutaq_custom_register_0_0.set_update_rate(1)
          
        self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_TX",4)
        self.nutaq_custom_register_0.set_index(1)
        self.nutaq_custom_register_0.set_update_rate(1)
          
        self.nutaq_carrier_perseus_TX = nutaq.carrier(0,"nutaq_carrier_perseus_TX", "192.168.0.101")
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate/1e4,True)
        self.blocks_tags_strobe_0 = blocks.tags_strobe(gr.sizeof_float*1, pmt.intern("TEST"), 1000, pmt.intern("strobe"))
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
        self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, 40)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_int_0_0_0 = blocks.float_to_int(1, 1)
        self.blocks_float_to_int_0_0 = blocks.float_to_int(1, 1)
        self.blocks_add_xx_0 = blocks.add_vff(1)
        self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate/1e5, analog.GR_COS_WAVE, 10, 1, 0)
        self.analog_const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 1e5*(2**32)/samp_rate)
        self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, ( cucala)/samp_rate*(2**32))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_float_to_int_0_0, 0), (self.nutaq_custom_register_0_1_0, 0))
        self.connect((self.blocks_float_to_int_0_0_0, 0), (self.nutaq_custom_register_0_1, 0))
        self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_int_0_0_0, 0))
        self.connect((self.analog_const_source_x_0_0, 0), (self.blocks_float_to_int_0_0, 0))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.spectsensing_subband_selector_0, 1))
        self.connect((self.blocks_stream_to_vector_0, 0), (self.spectsensing_subband_selector_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_vector_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.spectsensing_subband_selector_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_tags_strobe_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus", self.blocks_message_debug_0, "print")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus", self.blocks_message_debug_0, "print_pdu")
コード例 #52
0
ファイル: message_pdu.py プロジェクト: antiface/gr-ofdm_tools
            self.callback(msg_str)
        else:
            print msg_str
        if meta is not None:
            print "[METADATA]: ", meta


if __name__ == "__main__":
    import time
    # Create a flow graph
    tb = gr.top_block()
    # Create chat blocks
    chat_tx = message_pdu(None)
    chat_rx = message_pdu(None)
    pdu_to_tagged_stream = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
    tagged_stream_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
    # Connect them up
    tb.msg_connect(chat_tx, 'out',  chat_rx, 'in')
    # Start flow graph
    tb.start()
    chat_str = ""
    print "======= Chat/Message Passing Tester. Please type a message (type /quit to exit) ========="
    try:
        while chat_str != "/quit":
            chat_str = raw_input('> ')
            chat_tx.post_message("freq.", chat_str)
            time.sleep(0.1)
    except KeyboardInterrupt:
        print "\n"
    except EOFError:
        print "\n"
コード例 #53
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM PU Phy")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM PU Phy")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.taps = taps = filter.firdes.low_pass(1,samp_rate, 0.98e6,0.5e6)
        self.sync_word2 = sync_word2 = [0, 0, 0, 0, 0, 0, -1, -1, -1, -1, 1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 0, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, -1, -1, -1, -1, 0, 0, 0, 0, 0] 
        self.sync_word1 = sync_word1 = [0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 0., 0., 0., 0., 0.]
        self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),)
        self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),)
        self.packet_len = packet_len = 64
        self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),)
        self.len_tag_key = len_tag_key = "packet_len"
        self.interp_factor = interp_factor = 5
        self.fft_len = fft_len = 64
        self.decim_factor = decim_factor = 1

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.10.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(1255e6, 0)
        self.uhd_usrp_sink_0.set_gain(15, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc(
                interpolation=interp_factor,
                decimation=decim_factor,
                taps=(taps),
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc(
                interpolation=interp_factor,
                decimation=decim_factor,
                taps=(taps),
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc(
                interpolation=interp_factor,
                decimation=decim_factor,
                taps=(taps),
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
                interpolation=interp_factor,
                decimation=decim_factor,
                taps=(taps),
                fractional_bw=None,
        )
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  packet_length_tag_key=len_tag_key,
        	  occupied_carriers=occupied_carriers,
        	  pilot_carriers=pilot_carriers,
        	  pilot_symbols=pilot_symbols,
        	  sync_word1=sync_word1,
        	  sync_word2=sync_word2,
        	  bps_header=1,
        	  bps_payload=2,
        	  rolloff=0,
        	  debug_log=False,
        	  scramble_bits=False
        	 )
        self.dbconnect_packet_controller_0 = dbconnect.packet_controller(samp_rate/interp_factor, (10000,), 5, 10, 2, 20, 10, 5, 6643, 30000, (10,20,30), (0,1,2), True)
        self.dbconnect_cmd_pktgen_0 = dbconnect.cmd_pktgen("127.0.0.1", 5002, 64, True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.complex_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.09, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_3 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0)
        self.analog_sig_source_x_0_2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.dbconnect_packet_controller_0, 'in0'))    
        self.msg_connect((self.dbconnect_cmd_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        self.msg_connect((self.dbconnect_packet_controller_0, 'gcmd'), (self.blocks_message_debug_0, 'print'))    
        self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.dbconnect_cmd_pktgen_0, 'cmd'))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))    
        self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 1))    
        self.connect((self.analog_sig_source_x_0_2, 0), (self.blocks_multiply_xx_0_2, 1))    
        self.connect((self.analog_sig_source_x_0_3, 0), (self.blocks_multiply_xx_0_3, 1))    
        self.connect((self.blocks_add_xx_2, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0))    
        self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_2, 1))    
        self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_add_xx_2, 2))    
        self.connect((self.blocks_multiply_xx_0_3, 0), (self.blocks_add_xx_2, 3))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))    
        self.connect((self.dbconnect_packet_controller_0, 0), (self.rational_resampler_xxx_0_0, 0))    
        self.connect((self.dbconnect_packet_controller_0, 1), (self.rational_resampler_xxx_0_0_1, 0))    
        self.connect((self.dbconnect_packet_controller_0, 2), (self.rational_resampler_xxx_0_0_1_0, 0))    
        self.connect((self.dbconnect_packet_controller_0, 3), (self.rational_resampler_xxx_0_0_1_1, 0))    
        self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_multiply_xx_0, 0))    
        self.connect((self.rational_resampler_xxx_0_0_1, 0), (self.blocks_multiply_xx_0_1, 0))    
        self.connect((self.rational_resampler_xxx_0_0_1_0, 0), (self.blocks_multiply_xx_0_2, 0))    
        self.connect((self.rational_resampler_xxx_0_0_1_1, 0), (self.blocks_multiply_xx_0_3, 0))    
コード例 #54
0
ファイル: top_block.py プロジェクト: reysam93/GNURadio
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.pdu_length = pdu_length = 500
        self.lo_offset = lo_offset = 0
        self.gain = gain = 0.75
        self.freq = freq = 5890000000
        self.encoding = encoding = [0,0,0,0,0]
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.frequencyAdaptiveOFDM_mac_and_parse_0 = frequencyAdaptiveOFDM.mac_and_parse(([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, True, '/tmp/tx_packets.csv', '/tmp/rx_packets.csv')
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._pdu_length_range = Range(0, 1500, 1, 500, 200)
        self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int)
        self.top_layout.addWidget(self._pdu_length_win)
        self._lo_offset_options = (0, 6e6, 11e6, )
        self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self._gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0]
        self._freq_labels = ['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p']
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels: self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
        	lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)

        def _encoding_probe():
            while True:
                val = self.frequencyAdaptiveOFDM_mac_and_parse_0.get_encoding()
                try:
                    self.set_encoding(val)
                except AttributeError:
                    pass
                time.sleep(1.0 / (1000))
        _encoding_thread = threading.Thread(target=_encoding_probe)
        _encoding_thread.daemon = True
        _encoding_thread.start()

        self._chan_est_options = 0, 1, 3, 2
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()
        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)
            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)
        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._chan_est_box.addWidget(radio_button)
        	self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
        	lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier(
            bandwidth=10e6,
            chan_est=0,
            encoding=encoding,
            frequency=5.89e9,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(('', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna("TX/RX", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(('', "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	'packet_len',
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	300000, #samp_rate
        	"Data Received", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

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

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

        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_layout.addWidget(self._qtgui_time_sink_x_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(
            gr.sizeof_float,
            0,
            qtgui.NUM_GRAPH_NONE,
            1
        )
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['Error Rate', '', '', '', '',
                  '', '', '', '', '']
        units = ['Percent', '', '', '', '',
                 '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")]
        factor = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 100)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
        	48*10, #size
        	"", #name
        	4 #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 = ['RB1', 'RB2', 'RB3', 'RB4', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "yellow", "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(4):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.frequencyAdaptiveOFDM_write_frame_data_0 = frequencyAdaptiveOFDM.write_frame_data('/tmp/snr.csv', '/tmp/encoding.csv', '/tmp/wifi_frame_delay.csv', True)
        self.frequencyAdaptiveOFDM_rb_const_demux_stream_0 = frequencyAdaptiveOFDM.rb_const_demux_stream('packet_len')
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_vector_source_x_0 = blocks.vector_source_b(range(100), True, 1, [])
        self.blocks_uchar_to_float_0 = blocks.uchar_to_float()
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len')
        self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, pdu_length, 'packet_len')
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False)
        self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.adaptiveOFDM_stream_spacer_0 = adaptiveOFDM.stream_spacer(blocks.byte_t, 500)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'frame data'), (self.frequencyAdaptiveOFDM_write_frame_data_0, 'frame data'))
        self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy in'))
        self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 'symbols_in'))
        self.connect((self.adaptiveOFDM_stream_spacer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0))
        self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.adaptiveOFDM_stream_spacer_0, 0))
        self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 1), (self.qtgui_const_sink_x_0, 1))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 2), (self.qtgui_const_sink_x_0, 2))
        self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 3), (self.qtgui_const_sink_x_0, 3))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_freq_adap_phy_hier_0, 0))
        self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))