mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 10:33:43 +08:00
Preserve CAN Signal Geometry Compatibility
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user