From 67009de9443634580294fbb5e9ee71fa2a3d6d8c Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sat, 28 Nov 2026 11:58:35 -0600 Subject: [PATCH] Preserve CAN Signal Geometry Compatibility --- opendbc_repo/opendbc/can/dbc.py | 13 ++++++++----- prebuilt.json | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/opendbc_repo/opendbc/can/dbc.py b/opendbc_repo/opendbc/can/dbc.py index 4d1c542acb..5fc88a8740 100644 --- a/opendbc_repo/opendbc/can/dbc.py +++ b/opendbc_repo/opendbc/can/dbc.py @@ -1,7 +1,7 @@ import re import os from collections.abc import Callable -from dataclasses import dataclass, field +from dataclasses import dataclass from functools import cache from opendbc import DBC_PATH, get_generated_dbcs @@ -66,10 +66,13 @@ class Signal: calc_checksum: 'Callable[[int, Signal, bytearray], int] | None' = None checksum_fields: tuple['Signal', ...] = () - max_counter: int = field(init=False) + counter_max_override: int | None = None - def __post_init__(self): - self.max_counter = (1 << self.size) - 1 + @property + def max_counter(self) -> int: + if self.counter_max_override is not None: + return self.counter_max_override + return (1 << self.size) - 1 def get_raw_value(self, dat: bytes | bytearray) -> int: if _native_raw_value is not None: @@ -240,7 +243,7 @@ def ford_setup_signal(sig: Signal, dbc_name: str, line_num: int) -> None: def rivian_setup_signal(sig: Signal, dbc_name: str, line_num: int) -> None: if sig.name.endswith("Counter"): sig.type = SignalType.COUNTER - sig.max_counter = 14 # 0 to 14, despite the 4-bit field + sig.counter_max_override = 14 # 0 to 14, despite the 4-bit field @dataclass diff --git a/prebuilt.json b/prebuilt.json index 12745ca6c1..d6a23f0b00 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "9a9ce501cc83d073d3a032b195b6d5283ab3e2e3fe5c188eb90138c87821d7c0", "schema_version": 1} +{"protected_inventory_sha256": "0164cea095883545069af657ba6b7b6b4ff9d8cff7c47f0467150976e96c406b", "schema_version": 1}