Пример #1
0
 def start(self):
     print "monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints())
     try:
         cmd = map(lambda a: [self.tool,
                                                     re.search("\d+\.\d+\.\d+\.\d+",a).group(0),
                                                     re.search("-p (\d+)",a).group(1)],
                                          gr.rpcmanager_get().endpoints())[0]
         print "running: %s"%(str(cmd))
         self.proc = subprocess.Popen(cmd);
         self.started = True
     except:
         self.proc = None
         print "failed to to start ControlPort Monitor on specified port"
Пример #2
0
 def start(self):
     print "monitor::endpoints() = %s" % (gr.rpcmanager_get().endpoints())
     try:
         cmd = map(lambda a: [self.tool,
                                                     re.search("\d+\.\d+\.\d+\.\d+",a).group(0),
                                                     re.search("-p (\d+)",a).group(1)],
                                          gr.rpcmanager_get().endpoints())[0]
         print "running: %s"%(str(cmd))
         self.proc = subprocess.Popen(cmd);
         self.started = True
     except:
         self.proc = None
         print "failed to to start ControlPort Monitor on specified port"
Пример #3
0
    def test_002(self):
        data = range(1, 9)

        self.src = blocks.vector_source_c(data)
        self.p1 = blocks.ctrlport_probe_c("aaa", "C++ exported variable")
        self.p2 = blocks.ctrlport_probe_c("bbb", "C++ exported variable")
        probe_name = self.p2.alias()

        self.tb.connect(self.src, self.p1)
        self.tb.connect(self.src, self.p2)
        self.tb.start()

        # Probes return complex values as list of floats with re, im
        # Imaginary parts of this data set are 0.
        expected_result = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        # Get all exported knobs
        ret = radio.get([probe_name + "::bbb"])
        for name in ret.keys():
            result = ret[name].value
            self.assertEqual(result, expected_result)

        self.tb.stop()
Пример #4
0
def get_block_times(ic, tbname):
    # Get available endpoint
    ep = gr.rpcmanager_get().endpoints()[0]

    # Initialize a simple Ice client from endpoint
    base = ic.stringToProxy(ep)
    radio = GNURadio.ControlPortPrx.checkedCast(base)

    # Get all blocks with stream connections in the flowgraph
    b = radio.get(["{0}::edge list".format(tbname)])
    tb_key = b.keys()[0]
    b = b[tb_key].value.split("\n")

    # Get all blocks with message connectiosn in flowgraph
    mb = radio.getRe(["{0}::msg edges list".format(tbname)])
    tb_key = mb.keys()[0]
    b += mb[tb_key].value.split("\n")
    b = filter(None, b)

    # Split the edges list, make a set of unique blocks in flowgraph
    blocks = set()
    for block in b:
        a = block.split("->")[0].split(":")[0]
        b = block.split("->")[1].split(":")[0]
        blocks.add(a)
        blocks.add(b)

    # For each block, extract the "total work time" Perf Counter
    times = dict()
    for b in blocks:
        key = b + "::total work time"
        t = radio.get([key])
        times[b] = float(t[key].value)

    return times
Пример #5
0
    def test_002(self):
        data = range(1,9)

        self.src = blocks.vector_source_c(data)
        self.p1 = blocks.ctrlport_probe_c("aaa","C++ exported variable")
        self.p2 = blocks.ctrlport_probe_c("bbb","C++ exported variable")
        probe_name = self.p2.alias()

        self.tb.connect(self.src, self.p1)
        self.tb.connect(self.src, self.p2)
        self.tb.start()

        # Probes return complex values as list of floats with re, im
        # Imaginary parts of this data set are 0.
        expected_result = [1, 0, 2, 0, 3, 0, 4, 0,
                           5, 0, 6, 0, 7, 0, 8, 0]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        # Get all exported knobs
        ret = radio.get([probe_name + "::bbb"])
        for name in ret.keys():
            result = ret[name].value
            self.assertEqual(result, expected_result)

        self.tb.stop()
    def test_002(self):
        data = range(1,9)

        self.src = blocks.vector_source_f(data, True)
        self.probe = blocks.ctrlport_probe2_f("samples","Floats",
                                              len(data), gr.DISPNULL)
        probe_name = self.probe.alias()

        self.tb.connect(self.src, self.probe)
        self.tb.start()

        expected_result = [1, 2, 3, 4, 5, 6, 7, 8,]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        # Get all exported knobs
        ret = radio.get([probe_name + "::samples"])
        for name in ret.keys():
            # Get data in probe, which might be offset; find the
            # beginning and unwrap.
            result = ret[name].value
            i = result.index(1.0)
            result = result[i:] + result[0:i]
            self.assertEqual(expected_result, result)

        self.tb.stop()
Пример #7
0
 def start(self):
     try:
         print("monitor::endpoints() = %s" %
               (gr.rpcmanager_get().endpoints()))
         ep = gr.rpcmanager_get().endpoints()[0]
         cmd = [
             self.tool,
             re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1),
             re.search(r"-p (\d+)", ep).group(1)
         ]
         print("running: %s" % (str(cmd)))
         self.proc = subprocess.Popen(cmd)
         self.started = True
     except:
         self.proc = None
         print(
             "Failed to to connect to ControlPort. Please make sure that you have Thrift installed and check your firewall rules."
         )
Пример #8
0
    def test_005(self):
        data = list(range(1, 9))

        self.src = blocks.vector_source_b(data, True)
        self.probe = blocks.ctrlport_probe2_b("samples", "Bytes", len(data),
                                              gr.DISPNULL)
        probe_name = self.probe.alias()

        self.tb.connect(self.src, self.probe)
        self.tb.start()

        expected_result = [
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
        ]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search(r"-p (\d+)", ep).group(1)

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(hostname,
                                             portnum,
                                             rpcmethod='thrift')
        radio = radiosys.client

        # Get all exported knobs
        ret = radio.getKnobs([probe_name + "::samples"])
        for name in list(ret.keys()):
            # Get data in probe, which might be offset; find the
            # beginning and unwrap.
            result = ret[name].value
            result = list(struct.unpack(len(result) * 'b', result))
            i = result.index(1)
            result = result[i:] + result[0:i]
            self.assertEqual(expected_result, result)

        self.tb.stop()
        self.tb.wait()
Пример #9
0
    def test_001(self):
        data = list(range(1,9))

        self.src = blocks.vector_source_c(data, True)
        self.probe = blocks.ctrlport_probe2_c("samples","Complex",
                                              len(data), gr.DISPNULL)
        probe_name = self.probe.alias()

        self.tb.connect(self.src, self.probe)
        self.tb.start()


        # Probes return complex values as list of floats with re, im
        # Imaginary parts of this data set are 0.
        expected_result = [1, 2, 3, 4,
                           5, 6, 7, 8]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search("-p (\d+)", ep).group(1)
        argv = [None, hostname, portnum]

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
        radio = radiosys.client

        # Get all exported knobs
        ret = radio.getKnobs([probe_name + "::samples"])
        for name in list(ret.keys()):
            # Get data in probe, which might be offset; find the
            # beginning and unwrap.
            result = ret[name].value
            i = result.index(complex(1.0, 0.0))
            result = result[i:] + result[0:i]
            self.assertComplexTuplesAlmostEqual(expected_result, result, 4)

        self.tb.stop()
        self.tb.wait()
Пример #10
0
    def test_002(self):
        data = list(range(1, 10))

        self.src = blocks.vector_source_c(data, True)
        self.p = blocks.nop(gr.sizeof_gr_complex)
        self.p.set_ctrlport_test(0)
        probe_info = self.p.alias()

        self.tb.connect(self.src, self.p)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search(r"-p (\d+)", ep).group(1)

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(hostname,
                                             portnum,
                                             rpcmethod='thrift')
        radio = radiosys.client

        self.tb.start()

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get all exported knobs
        key_name_test = probe_info + "::test"
        ret = radio.getKnobs([
            key_name_test,
        ])

        ret[key_name_test].value = 10
        radio.setKnobs({key_name_test: ret[key_name_test]})

        ret = radio.getKnobs([])
        result_test = ret[key_name_test].value
        self.assertEqual(result_test, 10)

        self.tb.stop()
        self.tb.wait()
    def test_002(self):
        data = range(1, 10)

        self.src = blocks.vector_source_c(data, True)
        self.p = blocks.nop(gr.sizeof_gr_complex)
        self.p.set_ctrlport_test(0);
        probe_info = self.p.alias()

        self.tb.connect(self.src, self.p)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search("-p (\d+)", ep).group(1)
        argv = [None, hostname, portnum]

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
        radio = radiosys.client

        self.tb.start()

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get all exported knobs
        key_name_test = probe_info+"::test"
        ret = radio.getKnobs([key_name_test,])

        ret[key_name_test].value = 10
        radio.setKnobs({key_name_test: ret[key_name_test]})

        ret = radio.getKnobs([])
        result_test = ret[key_name_test].value
        self.assertEqual(result_test, 10)

        self.tb.stop()
        self.tb.wait()
Пример #12
0
    def test_002(self):
        data = list(range(1, 9))

        self.src = blocks.vector_source_c(data)
        self.p1 = blocks.ctrlport_probe_c("aaa", "C++ exported variable")
        self.p2 = blocks.ctrlport_probe_c("bbb", "C++ exported variable")
        probe_name = self.p2.alias()

        self.tb.connect(self.src, self.p1)
        self.tb.connect(self.src, self.p2)
        self.tb.start()

        # Probes return complex values as list of floats with re, im
        # Imaginary parts of this data set are 0.
        expected_result = [1, 2, 3, 4, 5, 6, 7, 8]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search(r"-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search(r"-p (\d+)", ep).group(1)

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(hostname,
                                             portnum,
                                             rpcmethod='thrift')
        radio = radiosys.client

        # Get all exported knobs
        ret = radio.getKnobs([probe_name + "::bbb"])
        for name in list(ret.keys()):
            result = ret[name].value
            self.assertEqual(result, expected_result)

        self.tb.stop()
Пример #13
0
    def test_002(self):
        data = range(1,9)

        self.src = blocks.vector_source_c(data)
        self.p1 = blocks.ctrlport_probe_c("aaa","C++ exported variable")
        self.p2 = blocks.ctrlport_probe_c("bbb","C++ exported variable")
        probe_name = self.p2.alias()

        self.tb.connect(self.src, self.p1)
        self.tb.connect(self.src, self.p2)
        self.tb.start()

        # Probes return complex values as list of floats with re, im
        # Imaginary parts of this data set are 0.
        expected_result = [1, 2, 3, 4,
                           5, 6, 7, 8]

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]
        hostname = re.search("-h (\S+|\d+\.\d+\.\d+\.\d+)", ep).group(1)
        portnum = re.search("-p (\d+)", ep).group(1)
        argv = [None, hostname, portnum]

        # Initialize a simple ControlPort client from endpoint
        from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient
        radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
        radio = radiosys.client

        # Get all exported knobs
        ret = radio.getKnobs([probe_name + "::bbb"])
        for name in ret.keys():
            result = ret[name].value
            self.assertEqual(result, expected_result)

        self.tb.stop()
Пример #14
0
    def test_002(self):
        data = range(1, 10)

        self.src = blocks.vector_source_c(data, True)
        self.p = blocks.nop(gr.sizeof_gr_complex)
        self.p.set_ctrlport_test(0)
        probe_info = self.p.alias()

        self.tb.connect(self.src, self.p)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        self.tb.start()

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get all exported knobs
        key_name_test = probe_info + "::test"
        ret = radio.get([
            key_name_test,
        ])

        ret[key_name_test].value = 10
        radio.set({key_name_test: ret[key_name_test]})

        ret = radio.get([])
        result_test = ret[key_name_test].value
        self.assertEqual(result_test, 10)

        self.tb.stop()
        self.tb.wait()
Пример #15
0
    def test_002(self):
        data = range(1, 10)

        self.src = blocks.vector_source_c(data, True)
        self.p = blocks.nop(gr.sizeof_gr_complex)
        self.p.set_ctrlport_test(0);
        probe_info = self.p.alias()

        self.tb.connect(self.src, self.p)

        # Get available endpoint
        ep = gr.rpcmanager_get().endpoints()[0]

        # Initialize a simple Ice client from endpoint
        ic = Ice.initialize(sys.argv)
        base = ic.stringToProxy(ep)
        radio = GNURadio.ControlPortPrx.checkedCast(base)

        self.tb.start()

        # Make sure we have time for flowgraph to run
        time.sleep(0.1)

        # Get all exported knobs
        key_name_test = probe_info+"::test"
        ret = radio.get([key_name_test,])

        ret[key_name_test].value = 10
        radio.set({key_name_test: ret[key_name_test]})

        ret = radio.get([])
        result_test = ret[key_name_test].value
        self.assertEqual(result_test, 10)

        self.tb.stop()
        self.tb.wait()