CanBusBase: fix offset calculation (#28938)

pull/28941/head
Shane Smiskol 2 years ago committed by GitHub
parent af7b2e4dd4
commit f99ac84b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      selfdrive/car/__init__.py

@ -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)

Loading…
Cancel
Save