feat(usb-can): add isolated adapter runtime and confirmed CAN transactions

Package the adapter SDK boundary and runtime lifecycle. Confirm admitted CAN transactions, bound retained data and test failure paths with synthetic hardware.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:09:59 +03:00
parent f32c7b400b
commit 8b210258ca
30 changed files with 3336 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
"""Fetch the exact reviewed SDK; never execute vendor examples."""
import hashlib
import io
import json
import urllib.request
import zipfile
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def fetch():
lock = json.loads((ROOT / "packaging/sdk-lock.json").read_text())
with urllib.request.urlopen(lock["url"], timeout=30) as response:
data = response.read(lock["bytes"] + 1)
if len(data) != lock["bytes"] or hashlib.sha256(data).hexdigest() != lock["sha256"]:
raise ValueError("Vendor SDK differs from the reviewed lock")
with zipfile.ZipFile(io.BytesIO(data)) as archive:
content = archive.read(lock["library_member"])
if len(content) != lock["library_bytes"] or content[:6] != b"\x7fELF\x02\x01":
raise ValueError("Expected the pinned 64-bit little-endian ELF")
target = ROOT / "build/sdk"
target.mkdir(parents=True, exist_ok=True)
(target / "libcontrolcanfd.so").write_bytes(content)
result = {
"file": "libcontrolcanfd.so",
"bytes": len(content),
"sha256": hashlib.sha256(content).hexdigest(),
"source_sha256": lock["sha256"],
}
(target / "manifest.json").write_text(json.dumps(result, indent=2) + "\n")
for name in ("controlcanfd.h", "config.h", "main.cpp"):
(target / name).write_bytes(archive.read("USB-CAN-FD-B-Linux/VMware/x86-c/" + name))
print(json.dumps(result))
if __name__ == "__main__":
fetch()