Ejemplo n.º 1
0
    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")
Ejemplo n.º 2
0
    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")
Ejemplo n.º 3
0
 def test_001_t(self):
     # set up fg
     msg_meta = pmt.make_dict()
     msg_meta = pmt.dict_add(msg_meta, pmt.to_pmt("freq"),
                             pmt.to_pmt("val"))
     vec1 = [
         0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
         0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00,
         0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00
     ]
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src = blocks.message_strobe(msg, 10)
     dut = capture_tools.bit_sniffer(fade_out=500, hexadecimal=True)
     self.tb.msg_connect((src, "strobe"), (dut, "packets"))
     self.tb.start()
     time.sleep(5)
     vec1 = [0x01, 0x00, 0x01, 0x00, 0x01, 0x00]
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src.set_msg(msg)
     time.sleep(5)
     vec1 = [0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01]
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src.set_msg(msg)
     time.sleep(5)
     self.tb.stop()
Ejemplo n.º 4
0
    def test_001_t(self):
        data = [ord('t'), ord('e'), ord('s'), ord('t')]
        msg = pmt.list1(
            pmt.list2(pmt.string_to_symbol("msg_clear"),
                      pmt.init_u8vector(len(data), data)))
        filename_key = "secret.key"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_stored = debug.get_message(0)
        nonce = pmt.nth(0, msg_stored)
        msg_encrypted = pmt.nth(1, msg_stored)
        print pmt.symbol_to_string(pmt.nth(0, nonce)), pmt.u8vector_elements(
            pmt.nth(1, nonce))
        print pmt.symbol_to_string(pmt.nth(
            0,
            msg_encrypted)), pmt.u8vector_elements(pmt.nth(1, msg_encrypted))
Ejemplo n.º 5
0
    def test_004(self):
        # Test that the TCP server can stream PDUs <= the MTU size.
        port = str(random.Random().randint(0, 30000) + 10000)
        mtu = 10000
        srcdata = tuple(x % 256 for x in range(mtu))
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu)
        self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu)
        self.pdu_sink = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store")

        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()

        received = self.pdu_sink.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(mtu):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
Ejemplo n.º 6
0
    def test_001_t (self):
        # set up message

        msg1 = pmt.list3(pmt.string_to_symbol('id'),pmt.string_to_symbol('int'),pmt.from_long(42))
        msg2 = pmt.list3(pmt.string_to_symbol('value'),pmt.string_to_symbol('float'),pmt.from_float(3.1416))
        #msg3 = pmt.list3(pmt.string_to_symbol('text'),pmt.string_to_symbol('string'),pmt.string_to_symbol('some text'))
        msg = pmt.list2(msg1,msg2)

        # set up sql connection

        host = '127.0.0.1'
        port = 0 # default
        user = '******'
        password = '******'
        database = 'my_db'
        table = 'my_table'

        # set up flowgraph

        if 0: # Enable and disable here
            msg_src = blocks.message_strobe(msg,100)
            sql_connector = sql.msg_to_table(user,password,database,table,host,port)

            self.tb.msg_connect(msg_src,'strobe',sql_connector,'Msg in')

        # run flowgraph

        self.tb.start()
        sleep(0.2)
        self.tb.stop()
        self.tb.wait()
Ejemplo n.º 7
0
    def test_002(self):
        # Send a PDU through a pair of UDP sockets
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x64, 0x6f, 0x67, 0x65)
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        self.pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", port)

        self.dbg = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.dbg, "store")

        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()
        self.pdu_send = None
        self.pdu_recv = None

        received = self.dbg.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(4):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
Ejemplo n.º 8
0
    def test_004_es_source_pdus(self):
        print "test_004_es_source_pdus"       
        msg = pmt.cons( pmt.to_pmt( {"somekey":"val2", "somekey2":"someval2" } ), 
                        pmt.to_pmt( numpy.array( [0,1,2,3,4,5,6,7,8,9] , dtype=numpy.float32) ) );
        src = es.source([gr.sizeof_float], 8, 2);
        stb = blocks.message_strobe( msg, 100.0 );
        tb = gr.top_block();
        tb.msg_connect(stb, "strobe", src, "schedule_event");
        th = blocks.throttle(gr.sizeof_float, 1000*100);
        hd = blocks.head(gr.sizeof_float, 1000*100);
        snk = blocks.vector_sink_f();
        tb.connect(src,th,hd,snk);

        # TODO: this can not use run because it is 
        # subject to GNU Radio's shutdown msg block bug
        # for remaining upstream msg blocks ...
        #tb.run();

        # workaround
        tb.start();
        time.sleep(1);
        tb.stop();
        tb.wait();

        self.assertEqual( sum(snk.data())>0, True );
Ejemplo n.º 9
0
    def test_002 (self):
        # Send a PDU through a pair of UDP sockets
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x64, 0x6f, 0x67, 0x65)
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        self.pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", port)

        self.dbg = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.dbg, "store")

        self.tb.start ()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()
        self.pdu_send = None
        self.pdu_recv = None

        received = self.dbg.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(4):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
Ejemplo n.º 10
0
	def __init__(self, baudrate=19200, device="/dev/pts/4"):
		grc_wxgui.top_block_gui.__init__(self, title="Simple Message Passing Example")

		##################################################
		# Parameters
		##################################################
		self.baudrate = baudrate
		self.device = device

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

		##################################################
		# Blocks
		##################################################
		self.openavionics_serial_io_0 = openavionics.serial_io(device,0,baudrate,0,1,False)
		self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
		self.blocks_message_debug_0 = blocks.message_debug()

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.blocks_message_strobe_0, "strobe", self.openavionics_serial_io_0, "in")
		self.msg_connect(self.openavionics_serial_io_0, "out", self.blocks_message_debug_0, "print")
Ejemplo n.º 11
0
 def test_001_t (self):
     data = [ord('t'),ord('e'),ord('s'),ord('t')]
     msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"),pmt.init_u8vector(len(data),data)))
     filename_sk = "secret.key"
     filename_pk = "public.key"
     nacl.generate_keypair(filename_sk,filename_pk)
     
     strobe = blocks.message_strobe(msg, 100)
     encrypt_public = nacl.encrypt_public(filename_pk,filename_sk)
     debug = blocks.message_debug()
     
     self.tb.msg_connect(strobe,"strobe",encrypt_public,"Msg clear")
     self.tb.msg_connect(encrypt_public,"Msg encrypted",debug,"store")
     
     self.tb.start()
     sleep(0.15)
     self.tb.stop()
     self.tb.wait()
     
     # check results
     msg_stored = debug.get_message(0)
     nonce = pmt.nth(0,msg_stored)
     msg_encrypted = pmt.nth(1,msg_stored)
     print pmt.symbol_to_string(pmt.nth(0,nonce)), pmt.u8vector_elements(pmt.nth(1,nonce))
     print pmt.symbol_to_string(pmt.nth(0,msg_encrypted)), pmt.u8vector_elements(pmt.nth(1,msg_encrypted))
Ejemplo n.º 12
0
    def test_001_t(self):
        data = [ord("a"), ord("b"), ord("c"), ord("d")]
        msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"), pmt.init_u8vector(len(data), data)))
        filename_key = "secret.a"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        decrypt_secret = nacl.decrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", decrypt_secret, "Msg encrypted")
        self.tb.msg_connect(decrypt_secret, "Msg decrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_out = debug.get_message(0)
        msg_symbol = pmt.symbol_to_string(pmt.nth(0, pmt.nth(0, msg_out)))
        msg_decrypted = pmt.u8vector_elements(pmt.nth(1, pmt.nth(0, msg_out)))
        print msg_symbol, msg_decrypted
        print "msg_clear", data

        for k in range(len(data)):
            self.assertEqual(data[k], msg_decrypted[k])
Ejemplo n.º 13
0
    def encode_decode_test(self, payload_str="TEST", whitening=False, encode_crc=False, decode_crc=False):
        preamble = "01010101"
        sync1 = 0x2
        sync2 = 0x3
        sync_length = 2
        payload = [ord(c) for c in payload_str]

        strobe = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.to_pmt(payload)), 200)
        encoder = cc11xx_encoder.cc11xx_encoder(preamble=[int(preamble, 2)], syncword=[sync1, sync2], whitening=whitening, crc=encode_crc)
        pdu_to_stream = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        debug = blocks.message_debug()
        self.tb.msg_connect(strobe, "strobe", encoder, "in")
        self.tb.msg_connect(encoder, "out", pdu_to_stream, "pdus")

        unpack = blocks.packed_to_unpacked_bb(1, 0)

        acc_code_block =  digital.correlate_access_code_tag_bb(preamble, 0, "preamble")
        deframer = cc11xx.cc11xx_deframer_bb(sync1 ,sync2, whitening, decode_crc, sync_length)

        self.tb.connect(pdu_to_stream,unpack)
        self.tb.connect(unpack, acc_code_block)
        self.tb.connect(acc_code_block, deframer)
        self.tb.msg_connect((deframer, 'out'), (debug, 'store'))
        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        #Please get rid of this sleep if you know how!
        time.sleep(0.1)
        self.tb.stop()

        result_data = [i for i in pmt.to_python(pmt.cdr(debug.get_message(0)))]
        self.assertEqual(payload, result_data)
Ejemplo n.º 14
0
    def __init__(self, baudrate=19200, device="/dev/pts/4"):
        grc_wxgui.top_block_gui.__init__(
            self, title="Simple Message Passing Example")

        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.device = device

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

        ##################################################
        # Blocks
        ##################################################
        self.openavionics_serial_io_0 = openavionics.serial_io(
            device, 0, baudrate, 0, 1, False)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_message_strobe_0, "strobe",
                         self.openavionics_serial_io_0, "in")
        self.msg_connect(self.openavionics_serial_io_0, "out",
                         self.blocks_message_debug_0, "print")
Ejemplo n.º 15
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.simple_mac_0_0 = mac.simple_mac(1,0.1,10)
        self.simple_mac_0 = mac.simple_mac(0,0.1,10)
        self.mac_virtual_channel_encoder_0 = mac.virtual_channel_encoder(0,0)
        self.blocks_random_pdu_0 = blocks.random_pdu(5, 5)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.simple_mac_0, "to_radio", self.simple_mac_0_0, "from_radio")
        self.msg_connect(self.simple_mac_0_0, "to_radio", self.simple_mac_0, "from_radio")
        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.mac_virtual_channel_encoder_0, "in")
        self.msg_connect(self.mac_virtual_channel_encoder_0, "out", self.simple_mac_0_0, "from_app")
        self.msg_connect(self.simple_mac_0, "to_app", self.blocks_message_debug_0, "print_pdu")
Ejemplo n.º 16
0
    def test_003_trim_from_end(self):
        orig_array = np.array([1.1, 2.2, 3.3, 4.4, 5.5])
        expected_out_array = np.array([1.1, 2.2, 3.3])
        metadata = {'a': 1, 'b': 2}
        in_pmt = pmt.cons(pmt.to_pmt(metadata), pmt.to_pmt(orig_array))
        expected_pmt = pmt.cons(pmt.to_pmt(metadata),
                                pmt.to_pmt(expected_out_array))

        # We just need something connected to the trimmer block for
        # the flowgraph to compile, but we'll post messages to it directly
        src = blocks.message_strobe(pmt.PMT_NIL, 9999999)
        trimmer = pdu_trim_uvector(0, 2)
        snk = blocks.message_debug()

        self.tb.msg_connect((src, 'strobe'), (trimmer, 'in'))
        self.tb.msg_connect((trimmer, 'out'), (snk, 'store'))

        self.tb.start()
        trimmer.to_basic_block()._post(pmt.intern('in'), in_pmt)
        time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        # check data
        self.assertEqual(snk.num_messages(), 1)
        self.assertTrue(pmt.equal(snk.get_message(0), expected_pmt))
Ejemplo n.º 17
0
 def run_clear_test(filter_str, expected_tags):
     data, json_dict, data_path, json_path = self.make_file(
         "clearing",
         [{
             "core:sample_start": 0,
             "test:foo": 1,
             "test:foobar": 2,
             "test:bar": 3,
             "test:baz": 4,
             "blargh:foo": 5
         }]
     )
     anno_sink = sigmf.annotation_sink(
         data_path, sigmf.annotation_mode_clear(filter_str))
     # Strobe block is just here for the flowgraph to run
     strobe = blocks.message_strobe(pmt.to_pmt("asdf"), 1)
     tb = gr.top_block()
     tb.msg_connect(strobe, "strobe", anno_sink, "annotations")
     tb.start()
     tb.stop()
     tb.wait()
     with open(json_path, "r") as f:
         meta = json.load(f)
         anno_dict = meta["annotations"][0]
         expect_set = set(expected_tags)
         anno_keys = set(anno_dict.keys())
         self.assertIn("core:sample_start", anno_keys)
         anno_keys.remove("core:sample_start")
         self.assertEqual(anno_keys, expect_set,
                          "Key filtering is incorrect")
Ejemplo n.º 18
0
    def test_gwnblock_py(self):
        '''GWN block in Python test.
        '''

        tst_msg = "--- A message from message strobe"
        src = blocks.message_strobe(pmt.intern(tst_msg), 1000)
        blk_gwn = gwnblock_py(name="MsgPasser",
                              number_in=1,
                              number_out=1,
                              number_timers=0,
                              number_timeouts=0)
        dbg = blocks.message_debug()

        self.tb.msg_connect((src, "strobe"),
                            (blk_gwn, blk_gwn.ports_in[0].port))
        self.tb.msg_connect((blk_gwn, blk_gwn.ports_out[0].port),
                            (dbg, "print"))

        #self.tb.run()  # for flowgraphs that will stop on its own!
        self.tb.start()
        #mutex_prt(self.tb.msg_edge_list())
        #print tb.dump()

        time.sleep(8)

        #blk_gwn.stop_timers()
        print '\n--- gwnblock_py, timers stopped'
        time.sleep(2)

        self.tb.stop()
        self.tb.wait()
        print '\n--- top block stopped'

        return
Ejemplo n.º 19
0
    def test_010_t (self):
        # PHR prefixer to removal
        data_in = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(2*self.c.phy_packetsize_bytes,170))
        self.src = blocks.message_strobe(data_in,100)
        self.snk = blocks.message_debug()

        self.tb.msg_connect(self.src, "strobe", self.fragmentation, "in")
        self.tb.msg_connect(self.fragmentation, "out", self.phr_prefixer, "in")
        self.tb.msg_connect(self.phr_prefixer, "out", self.zeropadding, "in")
        self.tb.connect(self.zeropadding, self.demux)
        self.tb.connect((self.demux,0), self.codeword_mapper_I, self.interleaver_I, self.preamble_sfd_prefixer_I, (self.qpsk_mapper,0))
        self.tb.connect((self.demux,1), self.codeword_mapper_Q, self.interleaver_Q, self.preamble_sfd_prefixer_Q, (self.qpsk_mapper,1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper, self.dqcsk_demapper, self.dqpsk_demapper, self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper,0), self.preamble_sfd_removal_I, self.deinterleaver_I, self.codeword_demapper_I, (self.mux,0))        
        self.tb.connect((self.qpsk_demapper,1), self.preamble_sfd_removal_Q, self.deinterleaver_Q, self.codeword_demapper_Q, (self.mux,1)) 
        self.tb.connect(self.mux, self.zeropadding_removal) 
        self.tb.msg_connect(self.zeropadding_removal, "out", self.phr_removal, "in") 
        self.tb.msg_connect(self.phr_removal, "out", self.snk, "store")

        self.tb.start()
        time.sleep(0.3)
        self.tb.stop()

        msg_out1 = self.snk.get_message(0)
        msg_out2 = self.snk.get_message(1)
        data_out1 = pmt.to_python(msg_out1)[1]
        data_out2 = pmt.to_python(msg_out2)[1]
        ref = pmt.to_python(data_in)[1]
        self.assertTrue((data_out1==ref[:len(data_out1)]).all() and (data_out2==ref[:len(data_out2)]).all())  
Ejemplo n.º 20
0
    def test_004 (self):
        # Test that the TCP server can stream PDUs <= the MTU size.
        port = str(random.Random().randint(0, 30000) + 10000)
        mtu = 10000
        srcdata = tuple(x % 256 for x in range(mtu))
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu)
        self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu)
        self.pdu_sink = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store")

        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()

        received = self.pdu_sink.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(mtu):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
Ejemplo n.º 21
0
    def test_001_t(self):
        # set up message

        msg1 = pmt.list3(pmt.string_to_symbol('id'),
                         pmt.string_to_symbol('int'), pmt.from_long(42))
        msg2 = pmt.list3(pmt.string_to_symbol('value'),
                         pmt.string_to_symbol('float'), pmt.from_float(3.1416))
        #msg3 = pmt.list3(pmt.string_to_symbol('text'),pmt.string_to_symbol('string'),pmt.string_to_symbol('some text'))
        msg = pmt.list2(msg1, msg2)

        # set up sql connection

        host = '127.0.0.1'
        port = 0  # default
        user = '******'
        password = '******'
        database = 'my_db'
        table = 'my_table'

        # set up flowgraph

        if 0:  # Enable and disable here
            msg_src = blocks.message_strobe(msg, 100)
            sql_connector = sql.msg_to_table(user, password, database, table,
                                             host, port)

            self.tb.msg_connect(msg_src, 'strobe', sql_connector, 'Msg in')

        # run flowgraph

        self.tb.start()
        sleep(0.2)
        self.tb.stop()
        self.tb.wait()
Ejemplo n.º 22
0
    def test_001_t(self):
        data = [ord('a'), ord('b'), ord('c'), ord('d')]
        msg = pmt.list1(
            pmt.list2(pmt.string_to_symbol("msg_clear"),
                      pmt.init_u8vector(len(data), data)))
        filename_key = "secret.a"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        decrypt_secret = nacl.decrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", decrypt_secret,
                            "Msg encrypted")
        self.tb.msg_connect(decrypt_secret, "Msg decrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_out = debug.get_message(0)
        msg_symbol = pmt.symbol_to_string(pmt.nth(0, pmt.nth(0, msg_out)))
        msg_decrypted = pmt.u8vector_elements(pmt.nth(1, pmt.nth(0, msg_out)))
        print msg_symbol, msg_decrypted
        print "msg_clear", data

        for k in range(len(data)):
            self.assertEqual(data[k], msg_decrypted[k])
    def test_001_t (self):
        #  set up fg
        fft_len = 256
        cp_len = 32
        samp_rate = 32000
        data = np.random.choice([-1, 1], [100, fft_len])

        timefreq = np.fft.ifft(data, axis=0)

        #add cp
        timefreq = np.hstack((timefreq[:, -cp_len:], timefreq))

        # msg (only 4th and 5th tuples are needed)
        id1 = pmt.make_tuple(pmt.intern("Signal"), pmt.from_uint64(0))
        name = pmt.make_tuple(pmt.intern("OFDM"), pmt.from_float(1.0));
        id2 = pmt.make_tuple(pmt.intern("xxx"), pmt.from_float(0.0))
        id3 = pmt.make_tuple(pmt.intern("xxx"), pmt.from_float(0.0))
        id4 = pmt.make_tuple(pmt.intern("xxx"), pmt.from_float(256))
        id5 = pmt.make_tuple(pmt.intern("xxx"), pmt.from_float(32))
        msg = pmt.make_tuple(id1, name, id2, id3, id4, id5)

        tx = np.reshape(timefreq, (1, -1))

        # GR time!
        src = blocks.vector_source_c(tx[0].tolist(), True, 1, [])
        freq_offset = analog.sig_source_c(1, analog.GR_SIN_WAVE,
                                          50.0/samp_rate, 1.0, 0.0)
        mixer = blocks.multiply_cc()
        sync = inspector.ofdm_synchronizer_cc(4096)
        dst = blocks.vector_sink_c()
        dst2 = blocks.vector_sink_c()
        msg_src = blocks.message_strobe(msg, 0)

        # connect
        self.tb.connect(src, (mixer, 0))
        self.tb.connect(freq_offset, (mixer, 1))
        self.tb.connect(mixer, sync)
        self.tb.msg_connect((msg_src, 'strobe'), (sync, 'ofdm_in'))
        self.tb.connect(sync, dst)
        self.tb.connect(src, dst2)

        self.tb.start()
        time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        # check data
        output = dst.data()
        expect = dst2.data()

        # block outputs 0j until it has enough OFDM symbols to perform estimations
        k = (k for k in range(len(output)) if output[k] != 0j).next()

        # use 10,000 samples for comparison since block fails sometimes
        # for one work function
        output = output[k:k+10000]
        expect = expect[k:k+10000]

        self.assertComplexTuplesAlmostEqual2(expect, output, abs_eps = 0.001, rel_eps=10)
Ejemplo n.º 24
0
 def test_002_msg(self):
     print "test_002"
     
     msg = pmt.pmt_from_long(220)
     self.strobe = blocks.message_strobe(msg, 1000)        
     self.tb.msg_connect(self.strobe, "strobe", self.demux, self.msg_buf_name)
     
     self.tb.run()
Ejemplo n.º 25
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.dflood_dflood_3 = dflood.dflood(
          3, 0, 20, False, False,
          5, 65, 2, 120, 50, 0, 0.8, True, None
          )
        self.dflood_dflood_1 = dflood.dflood(
          1, 0, 20, False, False,
          1, 5, 0, 120, 50, 2, 0.8, True, None
          )
        self.dflood_dflood_0 = dflood.dflood(
          0, 0, 10, False, False,
          5, 65, 2, 120, 50, 2, 0.8, True, None
          )
        self.blocks_random_pdu_0 = blocks.random_pdu(6, 6, chr(0xFF), 2)
        self.blocks_message_strobe_3 = blocks.message_strobe(pmt.intern("TEST"), 20000)
        self.blocks_message_strobe_2_0 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_strobe_1 = blocks.message_strobe(pmt.intern("TEST"), 20000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 20000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.dflood_dflood_0, 'ctrl_in'))    
        self.msg_connect((self.blocks_message_strobe_1, 'strobe'), (self.dflood_dflood_1, 'ctrl_in'))    
        self.msg_connect((self.blocks_message_strobe_2_0, 'strobe'), (self.blocks_random_pdu_0, 'generate'))    
        self.msg_connect((self.blocks_message_strobe_3, 'strobe'), (self.dflood_dflood_3, 'ctrl_in'))    
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.dflood_dflood_3, 'from_app'))    
        self.msg_connect((self.dflood_dflood_0, 'to_app'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.msg_connect((self.dflood_dflood_0, 'to_radio'), (self.dflood_dflood_1, 'from_radio'))    
        self.msg_connect((self.dflood_dflood_1, 'to_radio'), (self.dflood_dflood_0, 'from_radio'))    
        self.msg_connect((self.dflood_dflood_1, 'to_radio'), (self.dflood_dflood_3, 'from_radio'))    
        self.msg_connect((self.dflood_dflood_3, 'to_radio'), (self.dflood_dflood_1, 'from_radio'))    
 def notest_debug(self):
     src = blocks.vector_source_c(range(100), False, 1, [])
     separator = inspector_test.signal_separator_c(32000, firdes.WIN_HAMMING, 0.1, 100)
     msg = pmt.make_vector(1, pmt.PMT_NIL)
     flanks = pmt.make_f32vector(2, 0.0)
     pmt.f32vector_set(flanks, 0, 12500)
     pmt.f32vector_set(flanks, 1, 20)
     pmt.vector_set(msg, 0, flanks)
     msg_src = blocks.message_strobe(msg, 100)
Ejemplo n.º 27
0
 def test_012(self):
     s, st, h, k = analog.sig_source_c(44100, analog.GR_COS_WAVE, 440, 1.0, 0.0), blocks.message_strobe(pmt.PMT_NIL, 100), blocks.head(gr.sizeof_gr_complex, 1000), test_hblk([gr.sizeof_gr_complex], 16)
     tb = gr.top_block()
     tb.connect(s,h,k)
     tb.msg_connect(st,"strobe",k,"msg_in")
     tb.start()
     time.sleep(1)
     tb.stop()
     tb.wait()
    def test_001_5x_pass (self):
        strobe = blocks.message_strobe(pmt.PMT_NIL, 25)
        ctr = pdu_utils.message_counter(pmt.intern("counter"))
        self.tb.msg_connect((strobe, 'strobe'), (ctr, 'msg'))

        self.tb.start()
        time.sleep(.135)
        self.tb.stop()
        self.tb.wait()

        self.assertEquals(5, ctr.get_ctr())
Ejemplo n.º 29
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_general_timeout")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_general_timeout")
        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", "Test_general_timeout")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.timeout_duration_ms = timeout_duration_ms = 1000
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.samp_rate = samp_rate = 320000
        self.develop_mode_list = develop_mode_list = [1, 3, 4, 16]

        ##################################################
        # Blocks
        ##################################################
        self.inets_general_timeout_0 = inets.general_timeout(1, 43, 1000, 1000, 1, 1)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 0, 1, 1, 1, 2, 1, 318, 2, 524, 2, 2, 1, 1, 0, ([2, 3]), ([1000, 1000]), 2)
        self.inets_frame_probe_0_0 = inets.frame_probe(1, 101, 0, 0, 0.01)
        self.inets_frame_probe_0 = inets.frame_probe(0, 100, 0, 0, 0.01)
        self.inets_frame_index_selector_0 = inets.frame_index_selector(0, 41, ([1,2,3,4,5]), 0)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, 100, 1, 1)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_dummy_source_0, 'output'), (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'), (self.inets_general_timeout_0, 'frame_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'), (self.inets_frame_index_selector_0, 'frame_in'))
        self.msg_connect((self.inets_general_timeout_0, 'expired_frame_out'), (self.inets_frame_probe_0, 'info_in'))
        self.msg_connect((self.inets_general_timeout_0, 'killed_frame_out'), (self.inets_frame_probe_0_0, 'info_in'))
Ejemplo n.º 30
0
    def test_ports_timer(self):
        print "\n===\n=== TEST message_timer_example input and output ports \n===\n"
        tst_msg = "--- A message from message strobe"
        src = blocks.message_strobe(pmt.intern(tst_msg), 1000)
        pss = gwncppvgb.message_timer_example("AAAA", 1000, 6, "BBBB", 500, 6)

        dbg = blocks.message_debug()
        self.tb.msg_connect((src, "strobe"), (pss, "in_port_0"))
        self.tb.msg_connect((pss, "out_port_0"), (dbg, "print"))

        self.tb.start()
        time.sleep(8)
        self.tb.stop()
Ejemplo n.º 31
0
    def test_005_some_wrong_length_packets(self):
        snk = prbs_sink_pdu(self.PACKET_LENGTH_BYTES * 8, self.PRBS_RESET_LEN,
                            self.NUM_GENERATED_PACKETS)

        # We just need something connected to the trimmer block for
        # the flowgraph to compile, but we'll post messages to it directly
        src = blocks.message_strobe(pmt.PMT_NIL, 9999999)

        self.tb.msg_connect((src, 'strobe'), (snk, 'all'))
        self.tb.msg_connect((src, 'strobe'), (snk, 'corrected'))

        self.tb.start()
        for packet in self.packets:
            snk.to_basic_block()._post(
                pmt.intern('all'), pmt.cons(pmt.PMT_NIL, pmt.to_pmt(packet)))
        for i, packet in enumerate(self.packets):
            if i == 10:
                packet = np.concatenate(
                    (packet, np.array([0, 0], dtype=np.uint8)))
            elif i == 20:
                packet = packet[:-2]
            snk.to_basic_block()._post(
                pmt.intern('corrected'),
                pmt.cons(pmt.PMT_NIL, pmt.to_pmt(packet)))
        time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        self.assertEqual(snk.statistics["Expected number of packets sent"],
                         200)
        self.assertEqual(snk.statistics["Total number of packets received"],
                         200)
        self.assertEqual(
            snk.statistics["Total number of correct packets after FEC"], 198)
        self.assertEqual(
            snk.statistics[
                "Total number of wrong length packets after FEC (This should be 0)"],
            2)
        self.assertEqual(
            snk.statistics[
                "Total number of erroneous packets after FEC (This should be 0)"],
            0)
        self.assertEqual(
            snk.statistics["Total number of unique packets after FEC"], 198)
        self.assertEqual(snk.statistics["Total number of duplicates"], 0)
        self.assertAlmostEqual(snk.statistics["Frame error rate"], 0.01)

        expected = np.ones([self.NUM_GENERATED_PACKETS])
        expected[10] = 0
        expected[20] = 0
        self.assertTrue(np.array_equal(snk.collected_packets, expected))
Ejemplo n.º 32
0
    def test_001_t(self):
        src = blocks.vector_source_c(list(range(10000)), False, 1, [])
        separator = inspector_test.signal_separator_c(
            32000, firdes.WIN_HAMMING, 0.1, 100, False,
            inspector_test.map_float_vector({0.0: [0.0]}))
        vec_sink = blocks.vector_sink_c(1)
        ext = inspector_test.signal_extractor_c(0)
        snk = blocks.vector_sink_c(1)
        # pack message
        msg = pmt.make_vector(1, pmt.PMT_NIL)
        flanks = pmt.make_f32vector(2, 0.0)
        pmt.f32vector_set(flanks, 0, 12500)
        pmt.f32vector_set(flanks, 1, 20)
        pmt.vector_set(msg, 0, flanks)

        msg_src = blocks.message_strobe(msg, 100)

        taps = filter.firdes.low_pass(1, 32000, 500, 50, firdes.WIN_HAMMING,
                                      6.76)

        self.tb.connect(src, separator)
        self.tb.connect(src, vec_sink)
        self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in'))
        self.tb.msg_connect((separator, 'sig_out'), (ext, 'sig_in'))
        self.tb.connect(ext, snk)

        self.tb.start()
        time.sleep(0.3)
        self.tb.stop()
        self.tb.wait()

        data = vec_sink.data()

        sig = numpy.zeros(len(vec_sink.data()), dtype=complex)
        for i in range(len(vec_sink.data())):
            sig[i] = data[i] * numpy.exp(
                -1j * 2 * numpy.pi * 12500 * i * 1 / 32000)

        taps = filter.firdes.low_pass(1, 32000, 900, 90, firdes.WIN_HAMMING,
                                      6.76)
        sig = numpy.convolve(sig, taps, 'full')
        out = numpy.empty([0])
        decim = 32000 / 20 / 100
        j = 0
        for i in range(len(sig) / decim):
            out = numpy.append(out, sig[j])
            j += decim

        data = snk.data()
        for i in range(min(len(out), len(data))):
            self.assertComplexAlmostEqual2(out[i], data[i], abs_eps=0.01)
Ejemplo n.º 33
0
 def test_012(self):
     import math
     exp = 1j * 440 / 44100
     src = blocks.vector_source_c([math.e**(exp * n) for n in range(10**6)])
     strobe = blocks.message_strobe(pmt.PMT_NIL, 100)
     head = blocks.head(gr.sizeof_gr_complex, 1000)
     test = test_hblk([gr.sizeof_gr_complex], 16)
     tb = gr.top_block()
     tb.connect(src, head, test)
     tb.msg_connect(strobe, "strobe", test, "msg_in")
     tb.start()
     time.sleep(0.5)
     tb.stop()
     tb.wait()
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Blocks
        ##################################################
        self.ec_ax25_decoder_b_0 = ec.ax25_decoder_b(True, 0, "")
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False)
        self.blocks_random_pdu_0 = blocks.random_pdu(256, 256, chr(0xFF), 1)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 2000)
        self.ax25_ax25_encoder_0 = ax25.ax25_encoder("SPACE ", "EARTH ", 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax25_ax25_encoder_0, 'pdu_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus'))    
        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.ax25_ax25_encoder_0, 'pdu_in'))    
        self.msg_connect((self.ec_ax25_decoder_b_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus'))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.ec_ax25_decoder_b_0, 0))    
Ejemplo n.º 35
0
    def test_debug_401(self):
        msg = pmt.intern("TESTING")
        src = blocks.message_strobe(msg, 500)
        snk = blocks.message_debug()

        tb = gr.top_block()
        tb.msg_connect(src, "strobe", snk, "store")
        tb.start()
        time.sleep(1)
        tb.stop()
        tb.wait()

        rec_msg = snk.get_message(0)
        self.assertTrue(pmt.eqv(rec_msg, msg))
Ejemplo n.º 36
0
    def __init__(self):
        gr.top_block.__init__(self, "TFG")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("TFG")
        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", "testNWK")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Blocks
        ##################################################
        self.tfg_test_nwk_0 = tfg.test_nwk()
        self.tfg_NWK_stack_0 = tfg.NWK_stack(True, True)
        self.tfg_MAC_stack_0 = tfg.MAC_stack(False, False)
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.foo_packet_pad_0 = foo.packet_pad(False, True, 0.1, 2000, 2000)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("A"), 1000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.tfg_test_nwk_0, 'entrada'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.tfg_MAC_stack_0, 'in(PHY)'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(PHY)'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))    
        self.msg_connect((self.tfg_MAC_stack_0, 'out(NWK)'), (self.tfg_NWK_stack_0, 'in(MAC)'))    
        self.msg_connect((self.tfg_NWK_stack_0, 'out(MAC)'), (self.tfg_MAC_stack_0, 'in(NWK)'))    
        self.msg_connect((self.tfg_test_nwk_0, 'salida'), (self.tfg_NWK_stack_0, 'in(APS)'))    
        self.connect((self.foo_packet_pad_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.foo_packet_pad_0, 0))    
Ejemplo n.º 37
0
    def test_ports (self):
        print "\n===\n=== TEST gwnblockc input and output ports \n===\n"
        tst_msg = "--- A test message from message strobe"
        src = blocks.message_strobe(pmt.intern(tst_msg), 1000)
        pss = gwncppvgb.gwnblockc("GWN test message 2", 10)
        dbg = blocks.message_debug() 
        self.tb.msg_connect( (src, "strobe"), (pss, "in_port_0") )
        self.tb.msg_connect( (pss, "out_port_0"), (dbg, "print") )
        #self.tb.msg_connect( (src, "port_out_0"), (dbg, "print") )
  

        self.tb.start ()
        time.sleep(6)
        self.tb.stop()
Ejemplo n.º 38
0
    def test_001_4x_pass(self):
        strobe = blocks.message_strobe(pmt.PMT_NIL, 25)
        gate = pdu_utils.message_gate(True)
        debug = blocks.message_debug()
        self.tb.msg_connect((strobe, 'strobe'), (gate, 'in'))
        self.tb.msg_connect((gate, 'out'), (debug, 'store'))

        self.tb.start()
        time.sleep(.11)
        self.tb.stop()
        self.tb.wait()

        self.assertEquals(4, gate.get_n_passed())
        self.assertEquals(4, debug.num_messages())
Ejemplo n.º 39
0
    def test_debug_401(self):
        msg = pmt.intern("TESTING")
        src = blocks.message_strobe(msg, 500)
        snk = blocks.message_debug()

        tb = gr.top_block()
        tb.msg_connect(src, "strobe", snk, "store")
        tb.start()
        time.sleep(1)
        tb.stop()
        tb.wait()

        rec_msg = snk.get_message(0)
        self.assertTrue(pmt.eqv(rec_msg, msg))
Ejemplo n.º 40
0
    def __init__(self):
        gr.top_block.__init__(self, "Nwk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Nwk")
        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", "nwk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

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

        ##################################################
        # Blocks
        ##################################################
        self.tfg_repetidor_caracteres_0 = tfg.repetidor_caracteres(2)
        self.tfg_mensaje_a_mayusculas_0 = tfg.mensaje_a_mayusculas()
        self.tfg_imprimir_mensajes_0 = tfg.imprimir_mensajes()
        self.tfg_NWK_stack_constructor_0 = tfg.NWK_stack_constructor(
            0x12, 0x24)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("asdfghk"), 1000)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.tfg_mensaje_a_mayusculas_0, 'entrada'))
        self.msg_connect((self.tfg_NWK_stack_constructor_0, 'out(MAC)'),
                         (self.tfg_repetidor_caracteres_0, 'entrada'))
        self.msg_connect((self.tfg_mensaje_a_mayusculas_0, 'salida'),
                         (self.tfg_NWK_stack_constructor_0, 'in(APS)'))
        self.msg_connect((self.tfg_repetidor_caracteres_0, 'salida'),
                         (self.tfg_imprimir_mensajes_0, 'entrada'))
Ejemplo n.º 41
0
	def test_001_t (self):
		# set up pmt
		in_2 = (-1,2,-3,4,5,0)
		in_3 = (1,2,3,4,5,0)
		in_4 = (1,-2.1,3,-4.2,5.9,0)
		
		pmt_1 = pmt.list2(pmt.string_to_symbol("rx_time"),pmt.from_long(0))
		pmt_2 = pmt.list2(pmt.string_to_symbol("test"),pmt.init_f32vector(6,in_2))
		pmt_3 = pmt.list2(pmt.string_to_symbol("velocity"),pmt.init_f32vector(6,in_3))
		pmt_4 = pmt.list2(pmt.string_to_symbol("test2"),pmt.init_f32vector(6,in_4))
		pmt_in = pmt.list4(pmt_1,pmt_2,pmt_3,pmt_4)
		
		# set up fg
		symbols = ("test", "test2")
		const_add = (1, -2)
		const_mult = (-5, 1)
		
		strobe = blocks.message_strobe(pmt_in,400);
		test = radar.msg_manipulator(symbols,const_add,const_mult)
		debug = blocks.message_debug()
		
		self.tb.msg_connect(strobe, "strobe", test, "Msg in")
		self.tb.msg_connect(test, "Msg out", debug, "store")
		self.tb.msg_connect(test, "Msg out", debug, "print")
		
		# run fg
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check data
		msg = debug.get_message(0)
		out_2 = pmt.f32vector_elements(pmt.nth(1,pmt.nth(1,msg)))
		out_3 = pmt.f32vector_elements(pmt.nth(1,pmt.nth(2,msg)))
		out_4 = pmt.f32vector_elements(pmt.nth(1,pmt.nth(3,msg)))
		
		ref_2 = [0]*6
		ref_3 = [0]*6
		ref_4 = [0]*6
		for k in range(6):
			ref_2[k] = (in_2[k]+const_add[0])*const_mult[0]
			ref_3[k] = in_3[k]
			ref_4[k] = (in_4[k]+const_add[1])*const_mult[1]
			
		for k in range(6): # do asserts
			self.assertAlmostEqual(ref_2[k],out_2[k],3)
			self.assertAlmostEqual(ref_3[k],out_3[k],3)
			self.assertAlmostEqual(ref_4[k],out_4[k],3)
Ejemplo n.º 42
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))
Ejemplo n.º 43
0
    def test_msg_strobe(self):
        print("\n===  Test 1, with GNU Radio message_strobe\n")
        tst_msg = "--- FROM message strobe TO msg_sink"
        src = blocks.message_strobe(pmt.intern(tst_msg), 1000)
        blk_sink = msg_sink()

        self.tb.msg_connect((src, "strobe"),
                            (blk_sink, blk_sink.ports_in[0].port))

        #self.tb.run()  # for flowgraphs that will stop on its own!
        self.tb.start()
        time.sleep(5)
        self.tb.stop()
        self.tb.wait()

        return
Ejemplo n.º 44
0
    def test_003_some_unfixable_packets(self):
        snk = prbs_sink_pdu(self.PACKET_LENGTH_BYTES * 8, self.PRBS_RESET_LEN,
                            self.NUM_GENERATED_PACKETS)

        # We just need something connected to the trimmer block for
        # the flowgraph to compile, but we'll post messages to it directly
        src = blocks.message_strobe(pmt.PMT_NIL, 9999999)

        self.tb.msg_connect((src, 'strobe'), (snk, 'all'))
        self.tb.msg_connect((src, 'strobe'), (snk, 'corrected'))

        self.tb.start()
        for packet in self.packets[:180]:
            snk.to_basic_block()._post(
                pmt.intern('all'), pmt.cons(pmt.PMT_NIL, pmt.to_pmt(packet)))
        for packet in self.packets[:160]:
            snk.to_basic_block()._post(
                pmt.intern('corrected'),
                pmt.cons(pmt.PMT_NIL, pmt.to_pmt(packet)))
        time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        self.assertEqual(snk.statistics["Expected number of packets sent"],
                         200)
        self.assertEqual(snk.statistics["Total number of packets received"],
                         180)
        self.assertEqual(
            snk.statistics["Total number of correct packets after FEC"], 160)
        self.assertEqual(
            snk.statistics[
                "Total number of wrong length packets after FEC (This should be 0)"],
            0)
        self.assertEqual(
            snk.statistics[
                "Total number of erroneous packets after FEC (This should be 0)"],
            0)
        self.assertEqual(
            snk.statistics["Total number of unique packets after FEC"], 160)
        self.assertEqual(snk.statistics["Total number of duplicates"], 0)
        self.assertAlmostEqual(snk.statistics["Frame error rate"], 0.2)

        self.assertTrue(
            np.array_equal(
                snk.collected_packets,
                np.concatenate((np.ones([self.NUM_GENERATED_PACKETS - 40]),
                                np.zeros([40])))))
Ejemplo n.º 45
0
    def concat_test (self, data_to_concat):
        payload = [0x00]
        strobe = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.to_pmt(payload)), 200)
        concatenator = data_concatenator(data_to_concat=data_to_concat)
        debug = blocks.message_debug()
        self.tb.msg_connect(strobe, "strobe", concatenator, "in")
        self.tb.msg_connect(concatenator, "out", debug, "store")

        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        #Please get rid of this sleep if you know how!
        time.sleep(0.1)
        self.tb.stop()

        result_data = pmt.to_python(pmt.cdr(debug.get_message(0)))
        self.assertEqual(payload + data_to_concat , result_data.tolist())
Ejemplo n.º 46
0
    def test_001_t (self):
        src = blocks.vector_source_c(range(10000), False, 1, [])
        separator = inspector_test.signal_separator_c(32000, firdes.WIN_HAMMING, 0.1, 100, False, inspector_test.map_float_vector({0.0:[0.0]}))
        vec_sink = blocks.vector_sink_c(1)
        ext = inspector_test.signal_extractor_c(0)
        snk = blocks.vector_sink_c(1)
        # pack message
        msg = pmt.make_vector(1, pmt.PMT_NIL)
        flanks = pmt.make_f32vector(2, 0.0)
        pmt.f32vector_set(flanks, 0, 12500)
        pmt.f32vector_set(flanks, 1, 20)
        pmt.vector_set(msg, 0, flanks)

        msg_src = blocks.message_strobe(msg, 100)

        taps = filter.firdes.low_pass(1, 32000, 500, 50, firdes.WIN_HAMMING, 6.76)

        self.tb.connect(src, separator)
        self.tb.connect(src, vec_sink)
        self.tb.msg_connect((msg_src, 'strobe'), (separator, 'map_in'))
        self.tb.msg_connect((separator, 'sig_out'), (ext, 'sig_in'))
        self.tb.connect(ext, snk)

        self.tb.start()
        time.sleep(0.3)
        self.tb.stop()
        self.tb.wait()

        data = vec_sink.data()

        sig = numpy.zeros(len(vec_sink.data()), dtype=complex)
        for i in range(len(vec_sink.data())):
            sig[i] = data[i]*numpy.exp(-1j*2*numpy.pi*12500*i*1/32000)

        taps = filter.firdes.low_pass(1, 32000, 900, 90, firdes.WIN_HAMMING, 6.76)
        sig = numpy.convolve(sig, taps, 'full')
        out = numpy.empty([0])
        decim = 32000/20/100
        j = 0
        for i in range(len(sig)/decim):
            out = numpy.append(out, sig[j])
            j += decim

        data = snk.data()
        for i in range(min(len(out), len(data))):
            self.assertComplexAlmostEqual2(out[i], data[i], abs_eps=0.01)
Ejemplo n.º 47
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


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

        ##################################################
        # Blocks
        ##################################################
        import pyqt
        from gnuradio import blocks
        self.strobe = blocks.message_strobe( 
                pmt.cons(
                    pmt.PMT_NIL,
                    pmt.to_pmt( numpy.random.normal( 0, 1, 256 ) )
                ), 
                500 )
                
        self.raster = raster_plot("")
        self._raster_win = self.raster;
        self.top_layout.addWidget(self._raster_win)
        self.msg_connect( self.strobe, "strobe", self.raster, "pdus" )
Ejemplo n.º 48
0
	def test_001_t (self):
		# set up fg
		num_mean = 1
		center_freq = 1
		antenna_gain_tx = 1
		antenna_gain_rx = 1
		usrp_gain_rx = 1
		amplitude = 1
		corr_factor = 1
		exponent = 1

		Range = (10, 20, 30)
		power = (15, 30, 45)

		pmt_range = pmt.list2(pmt.string_to_symbol('range'),pmt.init_f32vector(len(Range),Range))
		pmt_power = pmt.list2(pmt.string_to_symbol('power'),pmt.init_f32vector(len(power),power))
		pmt_misc = pmt.list2(pmt.string_to_symbol('misc'),pmt.init_f32vector(3,(1,2,3)))
		pmt_in = pmt.list3(pmt_misc,pmt_range,pmt_power)

		src = blocks.message_strobe(pmt_in, 300)
		est = radar.estimator_rcs(num_mean, center_freq, antenna_gain_tx, antenna_gain_rx, usrp_gain_rx, amplitude, corr_factor, exponent)
		snk = blocks.message_debug()
		self.tb.msg_connect(src,"strobe",est,"Msg in")
		self.tb.msg_connect(est,"Msg out",snk,"store")
		self.tb.msg_connect(est,"Msg out",snk,"print")
		
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()

		# check data

		msg = snk.get_message(0)

		wavel = 3e8/center_freq
		d_antenna_gain_abs_rx = 10**(antenna_gain_rx/10)
		d_antenna_gain_abs_tx = 10**(antenna_gain_tx/10)
		power_rx = power[0]**exponent / 10**(usrp_gain_rx/10);
		power_tx = amplitude

		rcs_ref = (4*math.pi)**(3)/(d_antenna_gain_abs_rx*d_antenna_gain_abs_tx*wavel**2)*Range[0]**4*power_rx/power_tx*corr_factor

		self.assertAlmostEqual( rcs_ref, pmt.f32vector_ref(pmt.nth(1,(pmt.nth(0,msg))),0), 4 ) # check rcs value
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

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

        ##################################################
        # Blocks
        ##################################################
        self.blocks_random_pdu_0 = blocks.random_pdu(32, 32, chr(0xFF), 1)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 10000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.ax25_pdu_prepend_append_0 = ax25.pdu_prepend_append(-6, -2, 0xAA)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax25_pdu_prepend_append_0, 'pdu_out'), (self.blocks_message_debug_0, 'print_pdu'))    
        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.ax25_pdu_prepend_append_0, 'pdu_in'))    
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
Ejemplo n.º 50
0
 def test_001_t (self):
     # set up fg
     self.trigger = blocks.message_strobe(pmt.cons(pmt.intern("trigger"), pmt.intern("dummycdr")),10)
     self.src_ref = ieee802_15_4.make_pair_with_blob((0,1,2,3))
     self.src_test = ieee802_15_4.make_pair_with_blob((0,1,4,3))
     self.snk = ieee802_15_4.compare_blobs()
     self.tb.msg_connect(self.trigger, "strobe", self.src_ref, "in")
     self.tb.msg_connect(self.trigger, "strobe", self.src_test, "in")
     self.tb.msg_connect(self.src_ref, "out", self.snk, "ref")
     self.tb.msg_connect(self.src_test, "out", self.snk, "test")
     self.tb.start()
     time.sleep(0.1)
     self.tb.stop()
     # check data
     bits_per_blob = 4*8
     errors_per_blob = 2.0
     ref_ber = errors_per_blob/bits_per_blob
     ber = self.snk.get_ber()
     print "ber: ", ber
     print "ref ber:", ref_ber
     self.assertTrue(ref_ber == ber)
Ejemplo n.º 51
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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

        ##################################################
        # Blocks
        ##################################################
        self.crypto_sym_ciph_desc_0 = crypto.sym_ciph_desc("aes-256-ofb", False, ())
        self.crypto_sym_enc_0 = crypto.sym_enc(self.crypto_sym_ciph_desc_0)
        self.crypto_sym_dec_0 = crypto.sym_dec(self.crypto_sym_ciph_desc_0)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.make_u8vector(16,65), 500)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.crypto_sym_enc_0, 'pdus'))    
        self.msg_connect((self.crypto_sym_dec_0, 'pdus'), (self.blocks_message_debug_0, 'print'))    
        self.msg_connect((self.crypto_sym_enc_0, 'pdus'), (self.crypto_sym_dec_0, 'pdus'))    
Ejemplo n.º 52
0
 def test_001_t (self):
     # set up fg
     msg_meta = pmt.make_dict()
     msg_meta = pmt.dict_add(msg_meta, pmt.to_pmt("freq"), pmt.to_pmt("val"))
     vec1 = [0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00];
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src = blocks.message_strobe(msg, 10)
     dut = capture_tools.bit_sniffer(fade_out=500, hexadecimal=True)
     self.tb.msg_connect((src, "strobe"), (dut, "packets"))
     self.tb.start ()
     time.sleep(5)
     vec1 = [0x01, 0x00, 0x01, 0x00, 0x01, 0x00];
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src.set_msg(msg);
     time.sleep(5)
     vec1 = [0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01];
     msg_vector = pmt.init_u8vector(len(vec1), vec1)
     msg = pmt.cons(msg_meta, msg_vector)
     src.set_msg(msg);
     time.sleep(5)
     self.tb.stop()
Ejemplo n.º 53
0
 def setUp (self):
     self.tb = gr.top_block ()
     
     # These are block parameters        
     msg_buf_name_in = "cell_id"
     msg_buf_name_out = "pilots"
     N_rb_dl = 6
     ant_port = 0
     
     # These parameters are regarded as "data"
     cell_id = 124
     
     # Set up msg inputs and outputs
     msg = pmt.pmt_from_long(cell_id)
     self.strobe = blocks.message_strobe(msg, 1000)
     self.dbg = blocks.message_debug()
     
     # UUT
     self.param = estimator_parameterizer_msg(msg_buf_name_in, msg_buf_name_out, N_rb_dl, ant_port)
     
     # Set up connections
     self.tb.msg_connect(self.strobe, "strobe", self.param, msg_buf_name_in)
     self.tb.msg_connect(self.param, msg_buf_name_out, self.dbg, "store")
Ejemplo n.º 54
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

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

        ##################################################
        # Blocks
        ##################################################
        self.tnc_hdlc_framer_0 = tnc.hdlc_framer(preamble_length=50, postamble_length=7,verbose=False, use_scrambler=False)
        self.tnc_hdlc_deframer_0 = tnc.hdlc_deframer()
        self.tnc_ax25_framer_0 = tnc.ax25_framer(mycall="KI4MTT",destcall="KI4MTS",verbose=True)
        self.tnc_ax25_deframer_0 = tnc.ax25_deframer(mycall="KI4MTT",verbose=True)
        self.blocks_random_pdu_0 = blocks.random_pdu(50, 50)
        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.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.tnc_hdlc_deframer_0, 0))

        ##################################################
        # Asynch Message 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.tnc_ax25_framer_0, "in")
        self.msg_connect(self.tnc_ax25_deframer_0, "out", self.blocks_message_debug_0, "print_pdu")
        self.msg_connect(self.tnc_ax25_framer_0, "out", self.tnc_hdlc_framer_0, "in")
        self.msg_connect(self.tnc_hdlc_framer_0, "out", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.tnc_hdlc_deframer_0, "out", self.tnc_ax25_deframer_0, "in")
    def __init__(self):
        gr.top_block.__init__(self, "Calibration Example")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Calibration Example")
        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", "calibration_example_gui_manual")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.speed_of_light = speed_of_light = 299792458
        self.antenna_spacing = antenna_spacing = 0.1
        self.variable_qtgui_chooser_0_1_1 = variable_qtgui_chooser_0_1_1 = 1
        self.variable_qtgui_chooser_0_1_0 = variable_qtgui_chooser_0_1_0 = 0
        self.variable_qtgui_chooser_0_0_0 = variable_qtgui_chooser_0_0_0 = 1
        self.variable_qtgui_chooser_0_0 = variable_qtgui_chooser_0_0 = 0
        self.samp_rate = samp_rate = 100000000/64
        self.gain_rx = gain_rx = 0
        self.center_freq = center_freq = speed_of_light/(2*antenna_spacing)
        self.cal_freq = cal_freq = 1024
        self.Shift_1 = Shift_1 = -4
        self.Shift_0 = Shift_0 = -4
        self.Shift = Shift = -4

        ##################################################
        # Blocks
        ##################################################
        self._variable_qtgui_chooser_0_1_1_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_1_labels = ("Not Started", "Start Save", )
        self._variable_qtgui_chooser_0_1_1_group_box = Qt.QGroupBox("Trigger Data Save")
        self._variable_qtgui_chooser_0_1_1_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._variable_qtgui_chooser_0_1_1_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_1_group_box.setLayout(self._variable_qtgui_chooser_0_1_1_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_1_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_1_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_1_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_1_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_1_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_1_options.index(i)))
        self._variable_qtgui_chooser_0_1_1_callback(self.variable_qtgui_chooser_0_1_1)
        self._variable_qtgui_chooser_0_1_1_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_1(self._variable_qtgui_chooser_0_1_1_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_1_group_box)
        self._variable_qtgui_chooser_0_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_0_group_box = Qt.QGroupBox("Distant Transmitter Enable")
        self._variable_qtgui_chooser_0_0_0_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._variable_qtgui_chooser_0_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_0_callback(self.variable_qtgui_chooser_0_0_0)
        self._variable_qtgui_chooser_0_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0_0(self._variable_qtgui_chooser_0_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_0_group_box)
        self._variable_qtgui_chooser_0_0_options = (0, 1, )
        self._variable_qtgui_chooser_0_0_labels = ("Enable", "Disable", )
        self._variable_qtgui_chooser_0_0_group_box = Qt.QGroupBox("Source Enable")
        self._variable_qtgui_chooser_0_0_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._variable_qtgui_chooser_0_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_0_group_box.setLayout(self._variable_qtgui_chooser_0_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_0_options.index(i)))
        self._variable_qtgui_chooser_0_0_callback(self.variable_qtgui_chooser_0_0)
        self._variable_qtgui_chooser_0_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_0(self._variable_qtgui_chooser_0_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_0_group_box)
        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, "Input")
        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, "Post Gain Correct")
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, "Post Phase Correct")
        self.top_layout.addWidget(self.tab)
        self._Shift_1_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_1_win = RangeWidget(self._Shift_1_range, self.set_Shift_1, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_1_win)
        self._Shift_0_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_0_win = RangeWidget(self._Shift_0_range, self.set_Shift_0, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_0_win)
        self._Shift_range = Range(-4, 4, 0.01, -4, 200)
        self._Shift_win = RangeWidget(self._Shift_range, self.set_Shift, "Shift", "counter_slider", float)
        self.top_layout.addWidget(self._Shift_win)
        self._variable_qtgui_chooser_0_1_0_options = (1, 0, )
        self._variable_qtgui_chooser_0_1_0_labels = ("Stop", "Running", )
        self._variable_qtgui_chooser_0_1_0_group_box = Qt.QGroupBox("Sync System")
        self._variable_qtgui_chooser_0_1_0_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._variable_qtgui_chooser_0_1_0_button_group = variable_chooser_button_group()
        self._variable_qtgui_chooser_0_1_0_group_box.setLayout(self._variable_qtgui_chooser_0_1_0_box)
        for i, label in enumerate(self._variable_qtgui_chooser_0_1_0_labels):
        	radio_button = Qt.QRadioButton(label)
        	self._variable_qtgui_chooser_0_1_0_box.addWidget(radio_button)
        	self._variable_qtgui_chooser_0_1_0_button_group.addButton(radio_button, i)
        self._variable_qtgui_chooser_0_1_0_callback = lambda i: Qt.QMetaObject.invokeMethod(self._variable_qtgui_chooser_0_1_0_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._variable_qtgui_chooser_0_1_0_options.index(i)))
        self._variable_qtgui_chooser_0_1_0_callback(self.variable_qtgui_chooser_0_1_0)
        self._variable_qtgui_chooser_0_1_0_button_group.buttonClicked[int].connect(
        	lambda i: self.set_variable_qtgui_chooser_0_1_0(self._variable_qtgui_chooser_0_1_0_options[i]))
        self.top_layout.addWidget(self._variable_qtgui_chooser_0_1_0_group_box)
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr0=192.168.70.2,addr1=192.168.20.2,addr2=192.168.30.2,addr3=192.168.50.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(4),
        	),
        )
        self.uhd_usrp_source_0_0.set_clock_source("external", 0)
        self.uhd_usrp_source_0_0.set_time_source("external", 0)
        self.uhd_usrp_source_0_0.set_clock_source("external", 1)
        self.uhd_usrp_source_0_0.set_time_source("external", 1)
        self.uhd_usrp_source_0_0.set_clock_source("external", 2)
        self.uhd_usrp_source_0_0.set_time_source("external", 2)
        self.uhd_usrp_source_0_0.set_clock_source("external", 3)
        self.uhd_usrp_source_0_0.set_time_source("external", 3)
        self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec())
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 0)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 1)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 1)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 2)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 2)
        self.uhd_usrp_source_0_0.set_center_freq(center_freq, 3)
        self.uhd_usrp_source_0_0.set_gain(gain_rx, 3)
        self.uhd_usrp_sink_0_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.80.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0_0.set_gain(30, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=192.168.40.2", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0_0.set_clock_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_source("mimo", 0)
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(center_freq, 0)
        self.uhd_usrp_sink_0_0.set_gain(10, 0)
        self.save_data_hier_0 = save_data_hier(
            keep=1,
            samples=2**22,
            skips=2**18,
            vec_size=1,
        )
        self.real_time_scope_hier_0_0_0 = real_time_scope_hier(
            npoints=3000,
            samp_rate=samp_rate,
        )
        self.tab_layout_2.addWidget(self.real_time_scope_hier_0_0_0)
        self.real_time_scope_hier_0 = real_time_scope_hier(
            npoints=3000,
            samp_rate=samp_rate,
        )
        self.tab_layout_0.addWidget(self.real_time_scope_hier_0)
        self.blocks_multiply_const_vxx_0_2 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_1),numpy.sin(Shift_1)), ))
        self.blocks_multiply_const_vxx_0_1 = blocks.multiply_const_vcc((complex(numpy.cos(Shift_0),numpy.sin(Shift_0)), ))
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((complex(numpy.cos(Shift),numpy.sin(Shift)), ))
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_double(variable_qtgui_chooser_0_1_1), 1000)
        self.blks2_valve_0_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0_0))
        self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(variable_qtgui_chooser_0_0))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, cal_freq, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'), (self.save_data_hier_0, 'Trigger'))    
        self.connect((self.analog_sig_source_x_0, 0), (self.blks2_valve_0, 0))    
        self.connect((self.analog_sig_source_x_0_0, 0), (self.blks2_valve_0_0, 0))    
        self.connect((self.blks2_valve_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.blks2_valve_0_0, 0), (self.uhd_usrp_sink_0_0_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.real_time_scope_hier_0_0_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.save_data_hier_0, 1))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.real_time_scope_hier_0_0_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_1, 0), (self.save_data_hier_0, 2))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.real_time_scope_hier_0_0_0, 3))    
        self.connect((self.blocks_multiply_const_vxx_0_2, 0), (self.save_data_hier_0, 3))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.blocks_multiply_const_vxx_0_1, 0))    
        self.connect((self.uhd_usrp_source_0_0, 3), (self.blocks_multiply_const_vxx_0_2, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 1), (self.real_time_scope_hier_0, 1))    
        self.connect((self.uhd_usrp_source_0_0, 2), (self.real_time_scope_hier_0, 2))    
        self.connect((self.uhd_usrp_source_0_0, 3), (self.real_time_scope_hier_0, 3))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.real_time_scope_hier_0_0_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.save_data_hier_0, 0))    
Ejemplo n.º 56
0
    def __init__(self):
        gr.top_block.__init__(self, "Ofdm Tx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Ofdm Tx")
        try:
             self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
             pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

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


        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 1e6
        self.packet_len = packet_len = 100
        self.len_tag_key = len_tag_key = "packet_len"
        self.gain = gain = 60
        self.fft_len = fft_len = 128

        ##################################################
        # Blocks
        ##################################################
        self._gain_layout = Qt.QVBoxLayout()
        self._gain_tool_bar = Qt.QToolBar(self)
        self._gain_layout.addWidget(self._gain_tool_bar)
        self._gain_tool_bar.addWidget(Qt.QLabel("gain"+": "))
        class qwt_counter_pyslot(Qwt.QwtCounter):
            def __init__(self, parent=None):
                Qwt.QwtCounter.__init__(self, parent)
            @pyqtSlot('double')
            def setValue(self, value):
                super(Qwt.QwtCounter, self).setValue(value)
        self._gain_counter = qwt_counter_pyslot()
        self._gain_counter.setRange(0, 90, 1)
        self._gain_counter.setNumButtons(2)
        self._gain_counter.setValue(self.gain)
        self._gain_tool_bar.addWidget(self._gain_counter)
        self._gain_counter.valueChanged.connect(self.set_gain)
        self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot)
        self._gain_slider.setRange(0, 90, 1)
        self._gain_slider.setValue(self.gain)
        self._gain_slider.setMinimumWidth(200)
        self._gain_slider.valueChanged.connect(self.set_gain)
        self._gain_layout.addWidget(self._gain_slider)
        self.top_layout.addLayout(self._gain_layout)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	device_addr="",
        	stream_args=uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(400e6, 0)
        self.uhd_usrp_sink_0.set_gain(gain, 0)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=2,
                decimation=1,
                taps=None,
                fractional_bw=None,
        )
        self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
        	  fft_len=fft_len, cp_len=fft_len/4,
        	  packet_length_tag_key=len_tag_key,
        	  bps_header=1,
        	  bps_payload=2,
        	  rolloff=0,
        	  debug_log=False,
        	  scramble_bits=True
        	 )
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(packet_len, 0xAA)), 1000)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0))
        self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")