runtime/xenomai.py
changeset 2015 4eeefc6a13fd
parent 2000 9fa2f8ede5d6
child 3750 f62625418bff
equal deleted inserted replaced
2014:e6ff712e20f8 2015:4eeefc6a13fd
       
     1 #!/usr/bin/env python
       
     2 # -*- coding: utf-8 -*-
       
     3 #
       
     4 # See COPYING.Runtime file for copyrights details.
       
     5 #
       
     6 
       
     7 from __future__ import absolute_import
     1 from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer
     8 from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer
       
     9 
       
    10 
     2 def TryPreloadXenomai():
    11 def TryPreloadXenomai():
     3     """
    12     """
     4     Xenomai 3 (at least for version <= 3.0.6) do not handle properly dlclose
    13     Xenomai 3 (at least for version <= 3.0.6) do not handle properly dlclose
     5     of shared objects whose dlopen did trigger xenomai_init.
    14     of shared objects whose dlopen did trigger xenomai_init.
     6     As a workaround, this pre-loads xenomai libraries that need to be 
    15     As a workaround, this pre-loads xenomai libraries that need to be
     7     initialized and call xenomai_init once for all.
    16     initialized and call xenomai_init once for all.
     8     
    17 
     9     Xenomai auto init of libs MUST be disabled (see --auto-init-solib in xeno-config)
    18     Xenomai auto init of libs MUST be disabled (see --auto-init-solib in xeno-config)
    10     """
    19     """
    11     try:
    20     try:
    12         for name in ["cobalt", "modechk", "copperplate", "alchemy"]:
    21         for name in ["cobalt", "modechk", "copperplate", "alchemy"]:
    13             globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
    22             globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
    14         cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))  
    23         cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))
    15     except:
    24     except Exception:
    16         pass
    25         pass