runtime/xenomai.py
author Edouard Tisserant
Fri, 15 Jun 2018 09:48:05 +0200
changeset 2188 7f59aa398669
parent 2000 9fa2f8ede5d6
child 2015 4eeefc6a13fd
permissions -rw-r--r--
WxGlade HMI extension now does only instanciate wx object who's name match extension's name. If no object match the name and no code is provided in 'start' user python code section, then a warning is issued
from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer
def TryPreloadXenomai():
    """
    Xenomai 3 (at least for version <= 3.0.6) do not handle properly dlclose
    of shared objects whose dlopen did trigger xenomai_init.
    As a workaround, this pre-loads xenomai libraries that need to be 
    initialized and call xenomai_init once for all.
    
    Xenomai auto init of libs MUST be disabled (see --auto-init-solib in xeno-config)
    """
    try:
        for name in ["cobalt", "modechk", "copperplate", "alchemy"]:
            globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
        cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))  
    except:
        pass