fix: parser — CAN multi-frame, ISO-TP, пустой {} в промпт, 91 тест

This commit is contained in:
Repinoid
2026-06-06 06:59:26 +04:00
parent f83a14a1ce
commit 1e8fd62039
3 changed files with 267 additions and 15 deletions
+6 -2
View File
@@ -52,9 +52,13 @@ def _parse_vin(result: dict, raw: str, decoded: str):
# Fallback: парсим VIN из raw HEX
if "49" in raw and ("02" in raw or "4902" in raw.replace(" ", "")):
clean = raw.replace(":", "").replace(" ", "").upper()
# Чистим: убираем CAN адресацию (N:), ISO-TP (10..), двоеточия
import re
clean = re.sub(r'^\d\s*:\s*', '', raw, flags=re.MULTILINE) # "0:" "1:"
clean = re.sub(r'\b(?:10|14|21|22)\s+', '', clean) # ISO-TP PCI
clean = clean.replace(":", "").replace(" ", "").upper()
if "490201" in clean:
hex_str = clean.split("490201")[-1][:34]
hex_str = clean.split("490201")[-1].replace("\n", "").replace("\r", "")[:34]
vin = ""
for i in range(0, len(hex_str) - 1, 2):
try: