runtime/xenomai.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Sun, 07 Apr 2019 21:08:07 +0200
changeset 2579 8fb5c6eddc72
parent 2015 4eeefc6a13fd
child 3750 f62625418bff
permissions -rw-r--r--
Conform to pep8 and pylint :

pep8 version: 2.3.1
./ConfigTreeNode.py:130:49: E231 missing whitespace after ','
./editors/Viewer.py:643:24: E128 continuation line under-indented for visual indent
./editors/Viewer.py:670:12: E221 multiple spaces before operator
./editors/Viewer.py:671:13: E221 multiple spaces before operator
./editors/Viewer.py:2138:52: E203 whitespace before ':'
./editors/Viewer.py:2139:66: W291 trailing whitespace
./controls/VariablePanel.py:154:25: E231 missing whitespace after ','
./controls/LocationCellEditor.py:88:1: W293 blank line contains whitespace
./controls/LocationCellEditor.py:191:25: E221 multiple spaces before operator
./controls/LocationCellEditor.py:200:17: E128 continuation line under-indented for visual indent

pylint 1.8.3,
************* Module controls.LocationCellEditor
controls/LocationCellEditor.py:200: [C0330(bad-continuation), ] Wrong continued indentation (add 9 spaces).
_("Selected location is identical to previous one"))
^ |
************* Module controls.VariablePanel
controls/VariablePanel.py:154: [E1601(print-statement), VariableTable.SetValue] print statement used
************* Module editors.Viewer
editors/Viewer.py:643: [C0330(bad-continuation), ] Wrong continued indentation (add 1 space).
self.GetAddMenuCallBack(self.AddNewComment))
^|
editors/Viewer.py:598: [W0612(unused-variable), Viewer.AddDivergenceMenuItems] Unused variable 'add_branch'
editors/Viewer.py:1655: [E0602(undefined-variable), Viewer.PopupConnectionMenu] Undefined variable 'variable_type'
editors/Viewer.py:1649: [W0612(unused-variable), Viewer.PopupConnectionMenu] Unused variable 'connection_type'
************* Module connectors.PYRO.PSK_Adapter
2015
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     1
#!/usr/bin/env python
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     2
# -*- coding: utf-8 -*-
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     3
#
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     4
# See COPYING.Runtime file for copyrights details.
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     5
#
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     6
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     7
from __future__ import absolute_import
2000
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
     8
from ctypes import CDLL, RTLD_GLOBAL, pointer, c_int, POINTER, c_char, create_string_buffer
2015
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
     9
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
    10
2000
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    11
def TryPreloadXenomai():
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    12
    """
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    13
    Xenomai 3 (at least for version <= 3.0.6) do not handle properly dlclose
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    14
    of shared objects whose dlopen did trigger xenomai_init.
2015
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
    15
    As a workaround, this pre-loads xenomai libraries that need to be
2000
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    16
    initialized and call xenomai_init once for all.
2015
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
    17
2000
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    18
    Xenomai auto init of libs MUST be disabled (see --auto-init-solib in xeno-config)
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    19
    """
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    20
    try:
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    21
        for name in ["cobalt", "modechk", "copperplate", "alchemy"]:
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    22
            globals()[name] = CDLL("lib"+name+".so", mode=RTLD_GLOBAL)
2015
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
    23
        cobalt.xenomai_init(pointer(c_int(0)), pointer((POINTER(c_char)*2)(create_string_buffer("prog_name"), None)))
4eeefc6a13fd Fix codestyle
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents: 2000
diff changeset
    24
    except Exception:
2000
9fa2f8ede5d6 Fixed random segfault happening when loading new PLC in runtime, when using Xenonai.
Edouard Tisserant
parents:
diff changeset
    25
        pass