CanBusBase: fix offset calculation (#28938)

This commit is contained in:
Shane Smiskol
2023-07-14 03:06:22 -07:00
committed by GitHub
parent af7b2e4dd4
commit f99ac84b5c
+1 -2
View File
@@ -1,5 +1,4 @@
# functions common among cars
import math
from collections import namedtuple
from typing import Dict, Optional
@@ -186,7 +185,7 @@ class CanBusBase:
def __init__(self, CP, fingerprint: Optional[Dict[int, Dict[int, int]]]) -> None:
if CP is None:
assert fingerprint is not None
num = math.ceil(max([k for k, v in fingerprint.items() if len(v)], default=1) / 4)
num = max([k for k, v in fingerprint.items() if len(v)], default=0) // 4 + 1
else:
num = len(CP.safetyConfigs)
self.offset = 4 * (num - 1)