|
| 1 | +# Python wrapper of realtime script |
| 2 | +# Copyright 2026 Hannes Diethelm <hannes.diethelm@gmail.com> |
| 3 | +# |
| 4 | +# This program is free software; you can redistribute it and/or modify |
| 5 | +# it under the terms of the GNU General Public License as published by |
| 6 | +# the Free Software Foundation; either version 2 of the License, or |
| 7 | +# (at your option) any later version. |
| 8 | +# |
| 9 | +# This program is distributed in the hope that it will be useful, |
| 10 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | +# GNU General Public License for more details. |
| 13 | +# |
| 14 | +# You should have received a copy of the GNU General Public License |
| 15 | +# along with this program; if not, write to the Free Software |
| 16 | +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | + |
| 18 | +import subprocess |
| 19 | + |
| 20 | +REALTIME="@REALTIME@" |
| 21 | + |
| 22 | +def verify() -> bool: |
| 23 | + #Checks if system is realtime compatible |
| 24 | + cmd = [REALTIME, "verify"] |
| 25 | + ret = subprocess.run(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL) |
| 26 | + if ret.returncode != 0 and ret.returncode != 1: |
| 27 | + raise RuntimeError("cmd \"" + " ".join(cmd) + "\" failed with status " + str(ret.returncode)) |
| 28 | + return ret.returncode==0; |
| 29 | + |
| 30 | +def status() -> bool: |
| 31 | + #Status: realtime core running (rtapi_app running or kernel modules active) |
| 32 | + #Note: rtapi_app running does not mean realtime compatibility! |
| 33 | + cmd = [REALTIME, "status"] |
| 34 | + ret = subprocess.run(cmd, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL) |
| 35 | + if ret.returncode != 0 and ret.returncode != 1: |
| 36 | + raise RuntimeError("cmd \"" + " ".join(cmd) + "\" failed with status " + str(ret.returncode)) |
| 37 | + return ret.returncode==0; |
0 commit comments