Detect SNG controllers and harden scanner lifecycle
This commit is contained in:
parent
76a9109c80
commit
c2a603dc93
|
|
@ -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.
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
"version": "1.0.1"
|
||||
},
|
||||
"stage_ui": {
|
||||
"version": "3.1.24"
|
||||
"version": "3.1.25"
|
||||
},
|
||||
"stage_avahi": {
|
||||
"version": "1.0.0"
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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 []
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
} catch (error) {}
|
||||
})();
|
||||
</script>
|
||||
<link rel="stylesheet" href="/console.css?v=3.1.24&rev=edge-runtime-profile-1">
|
||||
<link rel="stylesheet" href="/console.css?v=3.1.25&rev=edge-runtime-profile-1">
|
||||
</head>
|
||||
<body>
|
||||
<main class="shell">
|
||||
|
|
@ -109,7 +109,7 @@
|
|||
</main>
|
||||
<div id="menuBackdrop" class="menuBackdrop" hidden></div>
|
||||
<div id="toastStack" class="toastStack" aria-live="polite" aria-atomic="true"></div>
|
||||
<script src="/console.i18n.js?v=3.1.24&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.js?v=3.1.24&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.i18n.js?v=3.1.25&rev=edge-runtime-profile-1"></script>
|
||||
<script src="/console.js?v=3.1.25&rev=edge-runtime-profile-1"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -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" }
|
||||
]
|
||||
}
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"version": "3.1.24"
|
||||
"version": "3.1.25"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue