Make app vehicle-agnostic: JSON vehicle profiles + menu bar
Vehicle data is now DATA, not code. PIDs/scaling/DTCs/presets live in profiles/*.json; the app loads them at runtime, so it works across vehicles and others can contribute profiles (open source). Core: - obdcore/formula.py: safe AST evaluator for scaling formulas (A/B/... byte vars, Torque/FORScan convention). Only arithmetic/bitwise + min/max/abs/ round/int/float; names/attrs/arbitrary calls rejected at load -> a community profile CANNOT execute code. - obdcore/profile.py: load/save/list profiles; compiles each formula into a decode callable. registry.py now profile-backed (PidRegistry/DtcDatabase take a Profile); hardcoded Ford table removed. - store.py: clear()/snapshot()/export_csv() for capture management. Profiles: - profiles/ford-6.0-powerstroke.json (27 PIDs, verified formulas, DTCs) - profiles/generic-obd2.json (standard SAE Mode-01 base, any vehicle) - profiles/README.md (schema + formula language + contributing) GUI: - Menu bar: File (new/record/export/replay capture, quit), Profile (switch/ load/import/reload/edit-JSON/export, live profile list), View (Graph/Table views, gauges P2, toggle PID dock, normalize, light/dark theme), Help (about/confidence legend/profile info). - PID browser + presets rebuild on profile switch; added Table view; raw-JSON profile editor dialog (validates schema+formulas before saving). Tests: profiles load+compile, formula sandbox rejects hostile input, decoders still match real truck bytes, crank/derived/dead-PID/replay -- all 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:
+21
-12
@@ -1,20 +1,29 @@
|
||||
"""obdcore -- headless OBD-II acquisition core for the ford-obd project.
|
||||
"""obdcore -- headless, vehicle-agnostic OBD-II acquisition core.
|
||||
|
||||
Layered, GUI-agnostic foundation shared by the terminal tool and the
|
||||
forthcoming PySide6 + pyqtgraph Windows app:
|
||||
Vehicle data (PIDs, scaling, DTCs, presets) lives in JSON profiles under
|
||||
profiles/ -- loaded at runtime, not hardcoded -- so the app works across
|
||||
vehicles and others can contribute profiles.
|
||||
|
||||
link.py ElmLink -- ELM327 serial transport (+ MockLink in mock.py)
|
||||
registry.py PidRegistry -- verified Ford 6.0 PID table + DTC database
|
||||
scheduler.py PollScheduler -- prioritized round-robin polling engine
|
||||
store.py TimeSeriesStore -- ring buffers, min/max, record/replay
|
||||
formula.py safe A/B/... scaling-formula evaluator (no code execution)
|
||||
profile.py load/save/list vehicle profiles (JSON)
|
||||
registry.py PidRegistry / DtcDatabase model + lookups
|
||||
link.py ElmLink ELM327 serial transport (+ MockLink in mock.py)
|
||||
scheduler.py PollScheduler prioritized polling engine
|
||||
store.py TimeSeriesStore ring buffers + record/replay
|
||||
|
||||
See ARCHITECTURE.md for the full design and roadmap.
|
||||
See ARCHITECTURE.md and profiles/README.md.
|
||||
"""
|
||||
from .registry import PidRegistry, DtcDatabase, Pid, Dtc, PRESETS
|
||||
from .store import TimeSeriesStore, CsvRecorder, replay_csv
|
||||
from .registry import PidRegistry, DtcDatabase, Pid, Dtc
|
||||
from .profile import (Profile, load_profile, save_profile, list_profiles,
|
||||
profiles_dir, default_profile_path, load_default)
|
||||
from .formula import compile_formula, FormulaError
|
||||
from .store import TimeSeriesStore, CsvRecorder, replay_csv, export_csv
|
||||
from .scheduler import PollScheduler
|
||||
|
||||
__all__ = [
|
||||
"PidRegistry", "DtcDatabase", "Pid", "Dtc", "PRESETS",
|
||||
"TimeSeriesStore", "CsvRecorder", "replay_csv", "PollScheduler",
|
||||
"PidRegistry", "DtcDatabase", "Pid", "Dtc",
|
||||
"Profile", "load_profile", "save_profile", "list_profiles",
|
||||
"profiles_dir", "default_profile_path", "load_default",
|
||||
"compile_formula", "FormulaError",
|
||||
"TimeSeriesStore", "CsvRecorder", "replay_csv", "export_csv", "PollScheduler",
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user