K1LLLAGT/SAAB-SUITE

GitHub: K1LLLAGT/SAAB-SUITE

专为 SAAB/GM 车型设计的纯 Python 模块化诊断与刷写套件,提供从底层 CAN 通信到高阶 ECU 管理的完整工作流。

Stars: 0 | Forks: 0

SAAB Suite 一个专为 SAAB 9‑3 / 9‑5 车辆打造的现代化、模块化诊断与刷写环境。 SAAB Suite 提供: - CAN 总线通信(mock、virtual、远程 TCP) - UDS 和 KWP2000 诊断 - Tech2 模拟器(第二阶段) - SPS 风格的刷写工作流 - 标定与固件管理 - CAN 回放、日志与分析 - 在 Termux/Android、Linux 和 Windows 上全面支持 Python 3.13 本项目专为 OEM 级可靠性、整洁架构以及高扩展性而设计。 ` ✨ 特性 - RemoteTcpBus — 自定义 TCP CAN 传输 - Pure‑Python 栈 — 无需 Rust,无需原生 wheels - src/ 布局 — 现代、可维护的项目结构 - 适用于 CAN、ISO‑TP、UDS、KWP2000、J2534 的适配器 - 用于 ECU、DTC、标定、固件的领域模型 - 运行时配置系统 - CAN 日志回放引擎 - 用于离线开发的 Mock 模式 📦 安装 (Termux / Android) ` pkg update pkg install python git git clone ~/saab-suite cd ~/saab-suite python3 -m venv .venv . .venv/bin/activate pip install python-can pip install -e . ` ⚙️ 配置 创建: ` ~/.config/saab-suite/can.toml ` 示例: `toml mode = "remote" # mock | virtual | remote remote_host = "192.168.1.50" remote_port = 5000 virtual_channel = "vcan0" ` 🚗 快速开始 打开 CAN 接口 `python from saabsuite.adapters.can.remoteinterface import RemoteCanInterface iface = RemoteCanInterface() iface.open() print("CAN ready") ` 发送帧 `python from saabsuite.adapters.can.remoteinterface import CanFrame iface.send(CanFrame(0x7E0, b"\x01\x00")) ` 接收帧 `python print(iface.recv(1.0)) ` 🧰 诊断 (UDS) `python from saab_suite.diag.uds.client import UdsClient uds = UdsClient() print(uds.readdataby_identifier(0xF190)) # VIN ` 🧩 目录结构 ` saab-suite/ ├── src/saab_suite/ │ ├── adapters/ # CAN, UDS, ISO-TP, J2534, 回放 │ ├── domain/ # 车辆, ECU, DTC, 标定 │ ├── kernel/ # 核心类型 + 错误 │ ├── ports/ # 接口 │ ├── runtime/ # 配置 + 路径 │ ├── remotetcpbus.py │ └── ... ├── tools/ └── vendor/ ` 🧪 自检 `python from saabsuite.adapters.can.remoteinterface import RemoteCanInterface, CanFrame iface = RemoteCanInterface() iface.open() iface.send(CanFrame(0x7E0, b"\x01\x00")) print(iface.recv(1.0)) ` ✅ 2. docs/ 站点 (MkDocs 或 Sphinx) 您可以任选其一。 📘 MkDocs 结构 ` docs/ index.md installation.md configuration.md can_transport.md diagnostics.md tech2.md sps.md replay.md developer/ architecture.md adapters.md domain.md ports.md coding_style.md mkdocs.yml ` mkdocs.yml ` site_name: SAAB Suite theme: name: material nav: - Home: index.md - Installation: installation.md - Configuration: configuration.md - CAN Transport: can_transport.md - Diagnostics: diagnostics.md - Tech2 Emulator: tech2.md - SPS Flashing: sps.md - CAN Replay: replay.md - Developer Guide: - Architecture: developer/architecture.md - Adapters: developer/adapters.md - Domain Model: developer/domain.md - Ports & Interfaces: developer/ports.md - Coding Style: developer/coding_style.md ` 📚 Sphinx 结构 ` docs/ conf.py index.rst installation.rst configuration.rst can_transport.rst diagnostics.rst tech2.rst sps.rst replay.rst developer/ architecture.rst adapters.rst domain.rst ports.rst coding_style.rst ` ✅ 3. CLI 参考手册 假设您的 CLI 入口点是 saab: ` saab ├── can │ ├── open │ ├── send │ ├── recv │ └── test ├── uds │ ├── read-did │ ├── session │ └── dtc ├── tech2 │ ├── start │ ├── dtc │ └── info ├── sps │ ├── prepare │ ├── flash │ └── verify └── replay ├── play └── list ` 示例:saab can test ` saab can test 打开 CAN 接口,发送测试帧,并等待响应。 ` 示例:saab uds read-did 0xF190 ` 从目标 ECU 读取 VIN。 ` ✅ 4. 开发者入职指南 🧭 架构概述 SAAB Suite 使用端口与适配器(六边形)架构: - ports/ — 抽象接口 - adapters/ — 具体实现 - domain/ — 纯业务逻辑 - kernel/ — 共享类型 - runtime/ — 配置 + 环境 这使得硬件、协议和 UI 层相互隔离。 🛠️ 开发环境设置 ` git clone ~/saab-suite cd ~/saab-suite python3 -m venv .venv . .venv/bin/activate pip install -e . pip install pytest ruff mypy ` 🧪 运行测试 ` pytest -q ` 🧹 代码规范检查 ` ruff check . mypy src/ ` 🧩 添加新适配器 1. 在 adapters// 中创建一个类 2. 在 ports/ 中实现相应的接口 3. 在 runtime/ 中添加配置键 4. 在 tests/adapters/ 中添加测试 🔌 添加新 UDS 服务 1. 在 diag/uds/services.py 中添加一个方法 2. 在 diag/uds/client.py 中添加一个包装器 3. 添加测试 4. 将其记录在 docs/diagnostics.md 中
标签:Android, CAN总线, DSL, ECU刷写, GDS2, GM, IoT, J2534, KWP2000, PE 加载器, Python, SAAB, SPS编程, Tech2Win, Termux, TUI, UDS诊断, UI模块, 云资产清单, 售后诊断工具, 固件管理, 数字取证, 无后门, 标定, 汽车安全, 汽车维修, 汽车诊断, 物联网, 生成式AI安全, 纯Python, 自动化脚本, 虚拟机, 车载网络, 逆向工具, 逆向工程, 通用汽车