mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 02:13:41 +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
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "9a9ce501cc83d073d3a032b195b6d5283ab3e2e3fe5c188eb90138c87821d7c0", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "0164cea095883545069af657ba6b7b6b4ff9d8cff7c47f0467150976e96c406b", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user