26 lines
828 B
Python
26 lines
828 B
Python
from __future__ import annotations
|
|
|
|
import pathlib
|
|
from typing import Optional
|
|
|
|
from ..lin.base import LinInterface
|
|
|
|
|
|
class HexFlasher:
|
|
"""Stubbed ECU flasher over LIN.
|
|
|
|
Replace with your actual UDS flashing sequence. For now, just validates the file exists
|
|
and pretends to flash successfully.
|
|
"""
|
|
|
|
def __init__(self, lin: LinInterface) -> None:
|
|
self.lin = lin
|
|
|
|
def flash_hex(self, hex_path: str, *, erase: bool = True, verify: bool = True, timeout_s: float = 120.0) -> bool:
|
|
path = pathlib.Path(hex_path)
|
|
if not path.is_file():
|
|
raise FileNotFoundError(f"HEX file not found: {hex_path}")
|
|
# TODO: Implement real flashing over LIN (UDS). This is a placeholder.
|
|
# You might send specific frames or use a higher-level protocol library.
|
|
return True
|