diff --git a/docs/releases/console-3.1.25.md b/docs/releases/console-3.1.25.md new file mode 100644 index 0000000..c5f8129 --- /dev/null +++ b/docs/releases/console-3.1.25.md @@ -0,0 +1,9 @@ +# Edge Console 3.1.25 + +- Identify IOMX-SNG-500 applications installed on an ExBd Nano base with a + compound read-only fingerprint: the shared Nano identity plus SNG state, + error and power registers. +- Keep the ordinary ExBd Nano profile as a fallback when the application + fingerprint does not match. +- Retain the renewable scanner lease and abandoned-session recovery delivered + in Console 3.1.24. diff --git a/stage-releases.json b/stage-releases.json index 61e3b2a..a07e603 100644 --- a/stage-releases.json +++ b/stage-releases.json @@ -14,7 +14,7 @@ "version": "1.0.1" }, "stage_ui": { - "version": "3.1.24" + "version": "3.1.25" }, "stage_avahi": { "version": "1.0.0" diff --git a/stage_ui/console_core/backend/app.py b/stage_ui/console_core/backend/app.py index 9f9763c..4802ec2 100644 --- a/stage_ui/console_core/backend/app.py +++ b/stage_ui/console_core/backend/app.py @@ -60,7 +60,7 @@ APP_DIR = "/opt/iomatex-console" PUBLIC_DIR = os.path.join(APP_DIR, "public") PROVIDERS_DIR = os.path.join(APP_DIR, "providers.d") CONFIG_PATH = "/etc/iomatex/console.json" -UI_VERSION = "V 3.1.24" +UI_VERSION = "V 3.1.25" STORAGE_HEALTH_COMMAND = "/usr/local/sbin/iomatex-storage-health" ZONEINFO_ROOT = "/usr/share/zoneinfo" diff --git a/stage_ui/console_core/backend/modbus_backend.py b/stage_ui/console_core/backend/modbus_backend.py index d974789..074df23 100644 --- a/stage_ui/console_core/backend/modbus_backend.py +++ b/stage_ui/console_core/backend/modbus_backend.py @@ -2375,6 +2375,10 @@ def validate_profile(data: Dict[str, Any], source_path: str) -> Dict[str, Any]: if not isinstance(spec, dict): continue summary_registers[str(name)] = normalize_register_spec(spec) + confirmation_registers = [] + for spec in (data.get("detection") or {}).get("confirm") or []: + if isinstance(spec, dict): + confirmation_registers.append(normalize_register_spec(spec)) profile = { "family": family, "title": title or family, @@ -2393,6 +2397,7 @@ def validate_profile(data: Dict[str, Any], source_path: str) -> Dict[str, Any]: }, "registers": registers, "detection": normalize_detection_config(data, registers), + "confirmation_registers": confirmation_registers, "summary_registers": summary_registers, "io_relationship": data.get("io_relationship") if family == "n4d8c12" else None, "comm_profiles": data.get("comm_profiles") or [], @@ -3082,6 +3087,38 @@ def discover_devices( best_error = read_result.get("error_type") or best_error continue family_detection = evaluate_family_detection(profile, read_result, register) + if family_detection["state"] == "recognized" and profile.get("confirmation_registers"): + confirmation_results = [] + for confirmation in profile["confirmation_registers"]: + confirmation_result = read_register_spec( + profile=profile, + port=port, + slave=slave, + baud=int(baud), + parity=str(parity), + register=confirmation, + register_name="detection_confirmation", + timeout=timeout_value, + retries=retries_value, + ) + confirmation_results.append({ + "register": dict(confirmation), + "ok": bool(confirmation_result.get("ok")), + "values": confirmation_result.get("values") or [], + "error_type": confirmation_result.get("error_type") or "", + }) + if not confirmation_result.get("ok"): + break + family_detection["confirmationRegisters"] = confirmation_results + if len(confirmation_results) != len(profile["confirmation_registers"]) or not all( + item["ok"] for item in confirmation_results + ): + family_detection.update({ + "state": "confirmation_failed", + "familyKey": "", + "familyLabel": "Application fingerprint did not match", + "matched": False, + }) if log_collector and is_string_rule: decoded_family = family_detection.get("modelString") or family_detection.get("rawValue") or "" raw_registers = family_detection.get("rawRegisters") or [] diff --git a/stage_ui/console_core/backend/test_modbus_sng_detection.py b/stage_ui/console_core/backend/test_modbus_sng_detection.py new file mode 100644 index 0000000..8faec5a --- /dev/null +++ b/stage_ui/console_core/backend/test_modbus_sng_detection.py @@ -0,0 +1,37 @@ +import importlib.util +from pathlib import Path +import unittest + + +spec = importlib.util.spec_from_file_location( + "sng_modbus_backend", Path(__file__).with_name("modbus_backend.py") +) +modbus = importlib.util.module_from_spec(spec) +spec.loader.exec_module(modbus) +modbus.MODBUS_PROFILES_DIR = str(Path(__file__).resolve().parents[1] / "modbus_profiles") + + +class SngDetectionProfileTest(unittest.TestCase): + def test_sng_variant_precedes_generic_nano_and_requires_two_confirmations(self): + profiles = modbus.load_profiles() + families = [profile["family"] for profile in profiles] + self.assertLess(families.index("iomx_sng_500"), families.index("exbd_nano")) + + profile = next(item for item in profiles if item["family"] == "iomx_sng_500") + self.assertEqual("exbd nano", profile["detection"]["family_register"]["match"][0]) + self.assertEqual( + [(102, 2, "input"), (34, 1, "holding")], + [ + (item["address"], item["count"], item["type"]) + for item in profile["confirmation_registers"] + ], + ) + + def test_generic_nano_remains_available_as_fallback(self): + profile = next(item for item in modbus.load_profiles() if item["family"] == "exbd_nano") + self.assertFalse(profile["confirmation_registers"]) + self.assertIn("nano", profile["detection"]["family_register"]["match"]) + + +if __name__ == "__main__": + unittest.main() diff --git a/stage_ui/console_core/frontend/console.js b/stage_ui/console_core/frontend/console.js index b7d7d7e..66addd7 100644 --- a/stage_ui/console_core/frontend/console.js +++ b/stage_ui/console_core/frontend/console.js @@ -49,7 +49,7 @@ { mode: "test_by", label: "test.it-screen.by", host: "rest.test.it-screen.by" }, { mode: "custom", label: "Custom", host: "" } ]; - const UI_VERSION = "V 3.1.20"; + const UI_VERSION = "V 3.1.25"; const ITSCREEN_LOG_INITIAL_LINES = 50; const ITSCREEN_LOG_BUFFER_LIMIT = 300; const ITSCREEN_LOG_BATCH_MS = 250; diff --git a/stage_ui/console_core/frontend/index.html b/stage_ui/console_core/frontend/index.html index 694119d..ece2cb1 100644 --- a/stage_ui/console_core/frontend/index.html +++ b/stage_ui/console_core/frontend/index.html @@ -23,7 +23,7 @@ } catch (error) {} })(); - +
@@ -109,7 +109,7 @@
- - + + diff --git a/stage_ui/console_core/modbus_profiles/iomx_00_sng_500.json b/stage_ui/console_core/modbus_profiles/iomx_00_sng_500.json new file mode 100644 index 0000000..50560dd --- /dev/null +++ b/stage_ui/console_core/modbus_profiles/iomx_00_sng_500.json @@ -0,0 +1,97 @@ +{ + "family": "iomx_sng_500", + "title": "IOMATEX IOMX-SNG-500", + "display_name": "IOMATEX IOMX-SNG-500", + "transport": { + "protocol": "modbus_rtu", + "default_port": "/dev/ttyS3", + "default_baud": 9600, + "default_parity": "none", + "default_databits": 8, + "default_stopbits": 1, + "scan_baud": [9600], + "scan_parity": ["none"], + "zero_based": false + }, + "detection": { + "type": "string", + "function": "input", + "start": 201, + "count": 20, + "encoding": "ascii", + "cleanup": "collapse_spaces", + "label": "201..220 (input)", + "match": ["ExBd NANO"], + "confirm": [ + { + "address": 102, + "count": 2, + "type": "input", + "label": "SNG state/error (102..103 input)" + }, + { + "address": 34, + "count": 1, + "type": "holding", + "label": "SNG power (34 holding)" + } + ], + "empty_values": ["", "0", "65535"], + "timeout_quick": 1.8, + "timeout_deep": 3.2 + }, + "registers": { + "test_read": { + "address": 102, + "count": 2, + "type": "input" + }, + "slave_id": { + "address": 253, + "count": 1, + "type": "holding", + "rw": true + }, + "comm_profile": { + "address": 255, + "count": 1, + "type": "holding", + "rw": true + } + }, + "summary_registers": { + "model_string": { + "address": 201, + "count": 20, + "type": "input", + "decode_mode": "uint16", + "value_format": "ascii", + "cleanup": "collapse_spaces" + }, + "state": { + "address": 102, + "count": 1, + "type": "input", + "decode_mode": "uint16" + }, + "errors": { + "address": 103, + "count": 1, + "type": "input", + "decode_mode": "uint16" + }, + "power": { + "address": 34, + "count": 1, + "type": "holding", + "decode_mode": "uint16" + } + }, + "comm_profiles": [ + { "register_value": 0, "baud": 1200, "parity": "none", "label": "1200" }, + { "register_value": 1, "baud": 2400, "parity": "none", "label": "2400" }, + { "register_value": 2, "baud": 4800, "parity": "none", "label": "4800" }, + { "register_value": 3, "baud": 9600, "parity": "none", "label": "9600" }, + { "register_value": 4, "baud": 19200, "parity": "none", "label": "19200" } + ] +} diff --git a/stage_ui/version.json b/stage_ui/version.json index 39b33a2..d61fa18 100644 --- a/stage_ui/version.json +++ b/stage_ui/version.json @@ -1,3 +1,3 @@ { - "version": "3.1.24" + "version": "3.1.25" }