def __init__(self, myFifo, csv_file):
        global fifo_fd
        if verbose:
            logging.info("rmc_ipc __init__()...")
            logging.info("rmc_ipc __init__(), myFifo is " + str(myFifo))
            logging.info("rmc_ipc __init__(), csv_file is " + str(csv_file))
        self._re = re.compile('^Vehicle\.([a-zA-Z]+)')
        # open fifo for read/write non-blocking
        self._myFifo = myFifo
        self._signals = parse_csv(csv_file)
        if not self._signals:
            print("From rmc_ipc, ERROR: no signals could not be parsed from " + csv_file)
            sys.exit(1)
        fifo_fd = os.open(self._myFifo, os.O_RDWR | os.O_NONBLOCK)
        if verbose:
            logging.info("rmc_ipc init(), the fifo_fd is " + str(fifo_fd))

        self.client_func = dstc.register_client_function("set_fm_frequency", "d")

        self._ctx = vsd.create_context()
        vsd.set_callback(self._ctx, process_signal)
        if vsd.load_from_file(self._ctx, "./vss_rel_2.0.0-alpha+005.csv") != 0:
            print("Could not load vss_rel_2.0.0-alpha+005.csv")
            sys.exit(255)
        sig = vsd.signal(self._ctx, "Vehicle.setfrequency");
        vsd.subscribe(self._ctx, sig)

        if verbose:
            logging.info("rmc_ipc is waiting for remote dstc function")
        dstc.activate()

        # 100000 seems enough
        # increase this value if tests timeout
        # also see dstc.process_events() in send()
        while not dstc.remote_function_available(self.client_func):
            dstc.process_events(100000)

        if verbose:
            logging.info("From class RMCIPC, init complete")
Exemple #2
0
#
import dstc

do_exit = False

def double_value_callback(doubled_value):
    global do_exit
    print("Callback-delivered value: {}".format(doubled_value))
    do_exit = True

if __name__ == "__main__":
    # Setup a client call to the server that will double the value for us.
    # double_value_server() takes an integer ("i") with the value to double
    # and a callback ("&") that double_value_server() is to invoke
    # on this process in order to deliver the result.
    client_func = dstc.register_client_function("double_value_server", "i&")
    dstc.activate()

    print("Waiting for remote function")
    while not dstc.remote_function_available(client_func):
        dstc.process_events(100000)

    #
    # Call the server's double_value_server() function, providing 21
    # as the value to double.
    #
    # The second argument, (double_value_callback, "i"), matches the
    # ampersand in the "i&" and specifies the local function
    # (double_value_callback()) that the remote double_value_server()
    # function is to invoke in order to deliver the result.
    #
#!/usr/bin/env python3
# Test python client to exercise DSTC.
import dstc


if __name__ == "__main__":
    client_func = dstc.register_client_function("print_name_and_age", "32si")
    dstc.activate()

    print("Waiting for remote function")
    while not dstc.remote_function_available(client_func):
        dstc.process_events(100000)

    client_func("Jane Doe", 32)
    dstc.process_events(10000)
Exemple #4
0
#!/usr/bin/env python3
# Test python client to exercise DSTC.
import dstc


if __name__ == "__main__":
    client_func = dstc.register_client_function("complex_arg", "32s#3i")
    dstc.activate()

    print("Waiting for remote function")
    while not dstc.remote_function_available(client_func):
        dstc.process_events(100000)

    client_func("32 byte string", b"Dynamic string", [11,22,33])
    dstc.process_events(500)
#!/usr/bin/env python3
# Test python client to exercise DSTC.
import dstc


if __name__ == "__main__":
    client_func = dstc.register_client_function("test_dynamic_function", "#4i")
    dstc.activate()

    print("Waiting for remote function")
    while not dstc.remote_function_available(client_func):
        dstc.process_events(100000)

    client_func(b"Hello world\x00", [1,2,3,4])

    dstc.process_events(500)