Exemple #1
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()
    def __init__(self, host, port):
        argv = [None, host, port]
        radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
        self.radio = radiosys.client
        print(self.radio)

        vt_init_key = 'dtv_atsc_viterbi_decoder0::decoder_metrics'
        data = self.radio.getKnobs([vt_init_key])[vt_init_key]
        init_metric = numpy.mean(data.value)
        self._viterbi_metric = 100 * [
            init_metric,
        ]

        table_col_labels = ('Num Packets', 'Error Rate', 'Packet Error Rate',
                            'Viterbi Metric', 'SNR')

        self._fig = plt.figure(1, figsize=(12, 12), facecolor='w')
        self._sp0 = self._fig.add_subplot(4, 1, 1)
        self._sp1 = self._fig.add_subplot(4, 1, 2)
        self._sp2 = self._fig.add_subplot(4, 1, 3)
        self._plot_taps = self._sp0.plot([], [], 'k', linewidth=2)
        self._plot_psd = self._sp1.plot([], [], 'k', linewidth=2)
        self._plot_data = self._sp2.plot([], [],
                                         'ok',
                                         linewidth=2,
                                         markersize=4,
                                         alpha=0.05)

        self._ax2 = self._fig.add_subplot(4, 1, 4)
        self._table = self._ax2.table(cellText=[len(table_col_labels) * ['0']],
                                      colLabels=table_col_labels,
                                      loc='center')
        self._ax2.axis('off')
        cells = self._table.properties()['child_artists']
        for c in cells:
            c.set_lw(0.1)  # set's line width
            c.set_ls('solid')
            c.set_height(0.2)

        ani = animation.FuncAnimation(self._fig,
                                      self.update_data,
                                      frames=200,
                                      fargs=(self._plot_taps[0],
                                             self._plot_psd[0],
                                             self._plot_data[0], self._table),
                                      init_func=self.init_function,
                                      blit=True)
        plt.show()
    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()
Exemple #4
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()
Exemple #5
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()
Exemple #6
0
#!/usr/bin/python2

import sys
import pmt
from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient

args = sys.argv
if (len(args) < 4):
    sys.stderr.write(
        'Not enough arguments: simple_copy_controller.py <host> <port> [true|false]\n\n'
    )
    sys.exit(1)

hostname = args[1]
portnum = int(args[2])
msg = args[3].lower()
argv = [None, hostname, portnum]
radiosys = GNURadioControlPortClient(argv=argv, rpcmethod='thrift')
radio = radiosys.client

if (msg == 'true'):
    radio.postMessage('copy0', 'en', pmt.PMT_T)
elif (msg == 'false'):
    radio.postMessage('copy0', 'en', pmt.PMT_F)
else:
    sys.stderr.write('Unrecognized message: must be true or false.\n\n')
    sys.exit(1)
Exemple #7
0
#!/usr/bin/env python

from __future__ import unicode_literals
import sys
import pmt
from gnuradio.ctrlport.GNURadioControlPortClient import GNURadioControlPortClient

args = sys.argv
if (len(args) < 4):
    sys.stderr.write(
        'Not enough arguments: simple_copy_controller.py <host> <port> [true|false]\n\n'
    )
    sys.exit(1)

hostname = args[1]
portnum = int(args[2])
msg = args[3].lower()
radiosys = GNURadioControlPortClient(host=hostname,
                                     port=portnum,
                                     rpcmethod='thrift')
radio = radiosys.client

if (msg == 'true'):
    radio.postMessage('copy0', 'en', pmt.PMT_T)
elif (msg == 'false'):
    radio.postMessage('copy0', 'en', pmt.PMT_F)
else:
    sys.stderr.write('Unrecognized message: must be true or false.\n\n')
    sys.exit(1)
Exemple #8
0
    help="Port of Controlport instance on host (default=%(default)r)")
parser.add_argument(
    "-a",
    "--alias",
    default="gr uhd usrp sink0",
    help="The UHD block's alias to control (default=%(default)r)")
parser.add_argument("command", metavar="COMMAND")
parser.add_argument("value", metavar="VALUE")
args = parser.parse_args()

port = 'command'
cmd = args.command
val = args.value

if (cmd == "tune" or cmd == "time"):
    sys.stderr.write(
        "This application currently does not support the 'tune' or 'time' UHD "
        "message commands.\n\n")
    sys.exit(1)
elif (cmd == "antenna"):
    val = pmt.intern(val)
else:
    val = pmt.from_double(float(val))

radiosys = GNURadioControlPortClient(host=args.host,
                                     port=args.port,
                                     rpcmethod='thrift')
radio = radiosys.client

radio.postMessage(args.alias, port, pmt.cons(pmt.intern(cmd), val))