#2 (framework): bi-directional / service-function engine
Profile-defined UDS action sequences, run safely -- the framework for #2 (real per-vehicle actuator tests/resets are follow-on, added as verified profile data). - obdcore/actions.py: Action model + run_action() executing session (Mode 10) -> security (Mode 27 seed->key) -> command steps (2F/31/11/3E/... any hex) with positive/negative response checks. Security KEY algorithms are per-vehicle secrets and NOT bundled -- only trivial transforms (xor-ff/invert/add-ff) known; an action naming an unknown algorithm is BLOCKED (fails safe). Never synthesizes bytes -- runs only what the profile defines. validate_action() rejects malformed hex at load. - profile.py: load/save an actions[] block; ElmLink/MockLink read_raw(hex). - GUI: Diagnostics -> Service & Bi-directional dialog -- lists the profile's actions with risk badges; caution/danger gated behind a warning confirmation. - generic-obd2: two safe STANDARD actions (Tester-Present ping; ECU-Reset, caution + engine-off warning). PROFILE_SPEC.md documents the actions schema + safety rules. - tests/test_actions.py: runner, session+reset, security handshake, unknown-algo block, hex validation, profile load. All 5 suites pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016yT89n4zR4qbrySoSiEyZs
This commit is contained in:
@@ -79,5 +79,14 @@ class MockLink:
|
||||
"values": [("Engine RPM", 240, "rpm"), ("Coolant Temp", 33, "C"),
|
||||
("Engine Load", 18, "%"), ("Vehicle Speed", 0, "km/h")]}
|
||||
|
||||
def read_raw(self, hexcmd, timeout=2.0):
|
||||
# Return a UDS positive response (sid+0x40) so actions succeed in mock.
|
||||
h = hexcmd.replace(" ", "")
|
||||
sid = int(h[:2], 16)
|
||||
rest = [int(h[i:i + 2], 16) for i in range(2, len(h) - 1, 2)]
|
||||
if sid == 0x27 and len(rest) == 1: # security seed request -> return a seed
|
||||
return [0x67, rest[0], 0x11, 0x22, 0x33, 0x44]
|
||||
return [(sid + 0x40) & 0xFF] + rest
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user