示例#1
0
def main():
    #./ in the path name forces the current directory to be searched
    # instead of LD_LIBRARY_PATH (/lib, /usr/libm, etc)
    vsd.load_vss_shared_object("./example.so")

    sig = vsd.signal("Modem.DataLink.Status")
    if not sig:
        print("Could not resolve signal Modem.DataLink.Status")
        sys.exit(255)

    vsd.set(sig, "connecting")

    sig = vsd.signal("Modem.SignalStrength")
    if not sig:
        print("Could not resolve signal Modem.SignalStrength")
        sys.exit(255)

    vsd.set(sig, 12)

    pub = vsd.signal("Modem")

    dstc.activate()

    stop_ts = current_milli_time() + 400
    while (current_milli_time() < stop_ts):
        dstc.process_events(stop_ts - current_milli_time())

    vsd.publish(pub)

    dstc.process_pending_events()
示例#2
0
def main():
    vsd.load_vss_shared_object("./example.so")
    dstc.activate()
    vsd.set_callback(process_signal)
    sig = vsd.signal("Modem");
    if not sig:
        print("Could not resolve signal Modem")
        sys.exit(255)

    vsd.subscribe(sig)
    global exit_flag

    while not exit_flag:
        dstc.process_events(-1)
    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")
示例#4
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.
    #
    client_func(21, (double_value_callback, "i"))
示例#5
0
文件: vsd.py 项目: PDXostc/vsd_swig
def activate():
    dstc.activate()