Добавить поддержку GAS 167 и УМП, улучшить обмен по CAN и последовательному порту

This commit is contained in:
2026-10-11 21:23:21 +03:00
parent 3c0f6fd9e6
commit 20454ff7fa
17 changed files with 1797 additions and 37 deletions

View File

@@ -10,14 +10,33 @@ from .can_bridge import decode_frame
PROTOCOLS = (("auto", "Авто (ProtoCAN / Balsam)"),
("devboard", "DevBoard_V1 / SETCAN"),
("deif", "DEIF XDi-192 / CANopen"))
("deif", "DEIF XDi-192 / CANopen"),
("protocan", "ProtoCAN / GAS"),
("ump_balsam", "УМП / Balsam 167 (legacy CAN)"),
("ump1_gas167", "УМП 1 / ProtoCAN — карта GAS 167/v1"),
("ump2_gas167", "УМП 2 / ProtoCAN — карта GAS 167/v1"),
("ump_gas", "УМП / ProtoCAN GAS — новые ID 5000/6000"))
def decode_protocol(frame, protocol="auto"):
if protocol == "deif":
from .deif_xdi import decode
return decode(frame)
if protocol == "devboard":
if protocol == "ump_balsam":
from .balsam_can import decode
result = decode(frame.can_id, frame.data, ide=frame.ide, rtr=frame.rtr)
if result is not None:
return result
result = pc.Decoded(pc.ProtoCanId.parse(frame.can_id), len(frame.data),
bytes(frame.data), ide=frame.ide, rtr=frame.rtr,
protocol="BALZAM 167", message_label="Не Balsam 167")
result.summary = "УМП / Balsam 167: CAN ID или формат кадра не соответствует протоколу"
result.warnings.append(result.summary)
return result
if protocol in ("ump1_gas167", "ump2_gas167"):
from .ump_can import decode_gas167
return decode_gas167(frame, node=1 if protocol == "ump1_gas167" else 2)
if protocol in ("devboard", "protocan", "ump_gas"):
return pc.decode(frame.can_id, frame.data, ide=frame.ide, rtr=frame.rtr)
return decode_frame(frame)