From 42151e246cecd874f19c6eae2382580b34922532 Mon Sep 17 00:00:00 2001 From: Sven Sager Date: Tue, 31 Oct 2023 13:21:46 +0100 Subject: [PATCH] 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 --- src/revpimodio2/modio.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/revpimodio2/modio.py b/src/revpimodio2/modio.py index ef406c6..49abefd 100644 --- a/src/revpimodio2/modio.py +++ b/src/revpimodio2/modio.py @@ -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