Добавить протокол DEIF, диагностику CAN и сохранение сессий
This commit is contained in:
@@ -197,6 +197,9 @@ def _column_index(header: list[str], *aliases: str) -> int | None:
|
||||
def _parse_log_timestamp(value: str, reference: float, milliseconds: bool) -> float:
|
||||
"""Читает epoch, millis() либо часы из CSV без требования даты в файле."""
|
||||
text = value.strip()
|
||||
if re.match(r"\d{4}-\d{2}-\d{2}[T ]", text):
|
||||
from datetime import datetime
|
||||
return datetime.fromisoformat(text.replace("Z", "+00:00")).timestamp()
|
||||
clock = re.fullmatch(r"(\d{1,2}):(\d{2}):(\d{2})(?:[.,](\d{1,6}))?", text)
|
||||
if clock:
|
||||
fraction = float("0." + (clock.group(4) or "0"))
|
||||
@@ -229,14 +232,14 @@ def _parse_csv_frame(
|
||||
rtr_index = None
|
||||
time_key = "ms"
|
||||
else:
|
||||
time_index = _column_index(header, "Время", "time", "timestamp", "ms",
|
||||
time_index = _column_index(header, "Время", "Последний приём", "time", "timestamp", "ms",
|
||||
"millis", "time_ms", "timestamp_ms",
|
||||
"uptime_ms", "elapsed_ms", "t_ms")
|
||||
type_index = _column_index(header, "Тип", "type", "format", "fmt", "ide", "ext")
|
||||
id_index = _column_index(header, "ID", "identifier", "can_id", "canid",
|
||||
"ID (29 бит)")
|
||||
dlc_index = _column_index(header, "DLC", "len", "length")
|
||||
data_index = _column_index(header, "Данные (hex)", "data", "payload",
|
||||
data_index = _column_index(header, "Данные (hex)", "Данные", "data", "payload",
|
||||
"data_hex", "bytes", "DATA (8 байт)")
|
||||
rtr_index = _column_index(header, "RTR", "remote")
|
||||
if None in (time_index, id_index, dlc_index, data_index):
|
||||
@@ -286,7 +289,9 @@ def _parse_csv_frame(
|
||||
}
|
||||
stamp = _parse_log_timestamp(row[time_index], reference, milliseconds)
|
||||
relative = stamp < 1_000_000_000 and not ":" in row[time_index]
|
||||
return BoardFrame(stamp, extended, identifier, rtr, dlc, data, source="SD"), relative
|
||||
source_index = _column_index(header, "Канал", "source", "dir", "direction", "Направление") if header else None
|
||||
source = row[source_index].strip() if source_index is not None and source_index < len(row) else "SD"
|
||||
return BoardFrame(stamp, extended, identifier, rtr, dlc, data, source=source), relative
|
||||
|
||||
|
||||
def parse_sd_log(
|
||||
|
||||
Reference in New Issue
Block a user