fix: Check offset values of the devices for integers

In the event of a misconfiguration in PiCtory, it may happen that the
offset values are given as floating point numbers. These devices and
their IOs must ignore ModiO that it cannot be ensured which offset
is correct.

Signed-off-by: Sven Sager <akira@narux.de>
This commit is contained in:
2023-10-31 13:21:46 +01:00
parent f352cb63b6
commit 42151e246c

View File

@@ -302,6 +302,19 @@ class RevPiModIO(object):
# Devices initialisieren
err_names_check = {}
for device in sorted(lst_devices, key=lambda x: x["offset"]):
# Pre-check of values
if float(device.get("offset")) != int(device.get("offset")):
# Offset misconfigured
warnings.warn(
"Offset value {0} of device {1} on position {2} is invalid. "
"This device and all IOs are ignored.".format(
device.get("offset"),
device.get("name"),
device.get("position"),
)
)
continue
# VDev alter piCtory Versionen auf KUNBUS-Standard ändern
if device["position"] == "adap.":
device["position"] = 64