Merge branch 'upstream/openpilot/master-20231016-sync' into master-20231016

# Conflicts:
#	cereal
#	panda
#	selfdrive/car/hyundai/interface.py
#	selfdrive/car/hyundai/values.py
#	selfdrive/car/subaru/values.py
#	selfdrive/controls/controlsd.py
#	selfdrive/controls/plannerd.py
#	selfdrive/monitoring/dmonitoringd.py
This commit is contained in:
Jason Wen
2023-10-16 11:03:27 -04:00
303 changed files with 10109 additions and 27537 deletions
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env python3
import argparse
from openpilot.common.basedir import BASEDIR
from openpilot.tools.lib.logreader import MultiLogIterator
from openpilot.tools.lib.route import Route
from openpilot.selfdrive.car.fw_versions import match_fw_to_car
from openpilot.selfdrive.car.interfaces import get_interface_attr
ALL_FW_VERSIONS = get_interface_attr("FW_VERSIONS")
ALL_CARS = get_interface_attr("CAR")
PLATFORM_TO_PYTHON_CAR_NAME = {brand: {car.value: car.name for car in ALL_CARS[brand]} for brand in ALL_CARS}
BRAND_TO_PLATFORMS = {brand: [car.value for car in ALL_CARS[brand]] for brand in ALL_CARS}
PLATFORM_TO_BRAND = dict(sum([[(platform, brand) for platform in BRAND_TO_PLATFORMS[brand]] for brand in BRAND_TO_PLATFORMS], []))
def add_fw_versions(brand, platform, new_fw_versions):
filename = f"{BASEDIR}/selfdrive/car/{brand}/values.py"
with open(filename, "r") as f:
values_py = f.read()
for key in new_fw_versions.keys():
ecu, addr, subAddr = key
fw_version = new_fw_versions[key]
platform_start = values_py.index(f"CAR.{PLATFORM_TO_PYTHON_CAR_NAME[brand][platform]}: {{")
start = values_py.index(f"(Ecu.{ecu}, {hex(addr)}, {subAddr}): [", platform_start)
try:
end_str = "],\n"
end = values_py.index(end_str, start)
except ValueError:
end_str = "]\n"
end = values_py.index(end_str, start)
values_py = values_py[:end] + f" {fw_version},\n " + values_py[end:]
with open(filename, "w") as f:
f.write(values_py)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Auto fingerprint from a route")
parser.add_argument("route", help="The route name to use")
parser.add_argument("platform", help="The platform, or leave empty to auto-determine using fuzzy", default=None, nargs='?')
args = parser.parse_args()
route = Route(args.route)
lr = MultiLogIterator(route.qlog_paths())
carFw = None
carVin = None
carPlatform = None
for msg in lr:
if msg.which() == "carParams":
carFw = msg.carParams.carFw
carVin = msg.carParams.carVin
carPlatform = msg.carParams.carFingerprint
break
if carFw is None:
raise Exception("No fw versions in the provided route...")
if args.platform is None: # attempt to auto-determine platform with other fuzzy fingerprints
_, possible_platforms = match_fw_to_car(carFw, log=False)
if len(possible_platforms) != 1:
print(f"Unable to auto-determine platform, possible platforms: {possible_platforms}")
if carPlatform != "mock":
print("Using platform from route")
platform = carPlatform
else:
raise Exception("unable to determine platform, try manually specifying the fingerprint.")
else:
platform = list(possible_platforms)[0]
else:
platform = args.platform
print("Attempting to add fw version for: ", platform)
brand = PLATFORM_TO_BRAND[platform]
new_fw_versions = {}
for fw in carFw:
if fw.brand == brand:
addr = fw.address
subAddr = None if fw.subAddress == 0 else fw.subAddress
key = (fw.ecu.raw, addr, subAddr)
if key in ALL_FW_VERSIONS[brand][platform]:
fw_versions = set(ALL_FW_VERSIONS[brand][platform][key])
if fw.fwVersion not in fw_versions:
new_fw_versions[(fw.ecu, addr, subAddr)] = fw.fwVersion
if not new_fw_versions:
print("No new fw versions found...")
add_fw_versions(brand, platform, new_fw_versions)
+2 -2
View File
@@ -2,7 +2,7 @@
from typing import Dict
import cereal.messaging as messaging
from cereal.services import service_list
from cereal.services import SERVICE_LIST
TO_CHECK = ['carState']
@@ -20,7 +20,7 @@ if __name__ == "__main__":
t = sm.logMonoTime[s] / 1e9
if s in prev_t:
expected = 1.0 / (service_list[s].frequency)
expected = 1.0 / (SERVICE_LIST[s].frequency)
dt = t - prev_t[s]
if dt > 10 * expected:
print(t, s, dt)
+3 -3
View File
@@ -7,7 +7,7 @@ from pprint import pprint
from tqdm import tqdm
from typing import List, Tuple, cast
from cereal.services import service_list
from cereal.services import SERVICE_LIST
from openpilot.tools.lib.route import Route
from openpilot.tools.lib.logreader import LogReader
@@ -17,7 +17,7 @@ if __name__ == "__main__":
cnt_valid: Counter = Counter()
cnt_events: Counter = Counter()
cams = [s for s in service_list if s.endswith('CameraState')]
cams = [s for s in SERVICE_LIST if s.endswith('CameraState')]
cnt_cameras = dict.fromkeys(cams, 0)
alerts: List[Tuple[float, str]] = []
@@ -62,7 +62,7 @@ if __name__ == "__main__":
print("\n")
print("Cameras")
for k, v in cnt_cameras.items():
s = service_list[k]
s = SERVICE_LIST[k]
expected_frames = int(s.frequency * duration / cast(float, s.decimation))
print(" ", k.ljust(20), f"{v}, {v/expected_frames:.1%} of expected")
+2 -1
View File
@@ -25,7 +25,8 @@ def cycle_alerts(duration=200, is_metric=False):
(EventName.buttonCancel, ET.USER_DISABLE),
(EventName.wrongGear, ET.NO_ENTRY),
(EventName.vehicleModelInvalid, ET.SOFT_DISABLE),
(EventName.locationdTemporaryError, ET.SOFT_DISABLE),
(EventName.paramsdTemporaryError, ET.SOFT_DISABLE),
(EventName.accFaulted, ET.IMMEDIATE_DISABLE),
# DM sequence
+2 -2
View File
@@ -8,7 +8,7 @@ import cereal.messaging as messaging
from hexdump import hexdump
from cereal import log
from cereal.services import service_list
from cereal.services import SERVICE_LIST
codecs.register_error("strict", codecs.backslashreplace_errors)
@@ -31,7 +31,7 @@ if __name__ == "__main__":
poller = messaging.Poller()
for m in args.socket if len(args.socket) > 0 else service_list:
for m in args.socket if len(args.socket) > 0 else SERVICE_LIST:
messaging.sub_sock(m, poller, addr=args.addr)
values = None
@@ -62,6 +62,10 @@ SUPPORTED_FW_VERSIONS = {
b"TM__ SCC F-CUP 1.00 1.02 99110-S2000\x18\x07\x08\x18W ": ConfigValues(
default_config=b"\x00\x00\x00\x01\x00\x00",
tracks_enabled=b"\x00\x00\x00\x01\x00\x01"),
# 2021 K5 HEV
b"DLhe SCC FHCUP 1.00 1.02 99110-L7000 \x01 \x102 ": ConfigValues(
default_config=b"\x00\x00\x00\x01\x00\x00",
tracks_enabled=b"\x00\x00\x00\x01\x00\x01"),
}
if __name__ == "__main__":
+2 -2
View File
@@ -5,7 +5,7 @@ from collections import defaultdict
import matplotlib.pyplot as plt
from cereal.services import service_list
from cereal.services import SERVICE_LIST
from openpilot.tools.lib.logreader import LogReader
from openpilot.tools.lib.route import Route
@@ -49,7 +49,7 @@ if __name__ == "__main__":
msgs_by_type[m.which()].append(m.as_builder().to_bytes())
qlog_by_type = defaultdict(list)
for name, service in service_list.items():
for name, service in SERVICE_LIST.items():
if service.decimation is None:
continue
@@ -1,8 +0,0 @@
#!/bin/bash
set -e
cd "$( dirname "${BASH_SOURCE[0]}" )"
ssh "$1" '$HOME/one/external/simpleperf/bin/android/arm64/simpleperf record --call-graph fp -a --duration 10 -o /tmp/perf.data'
scp "$1":/tmp/perf.data /tmp/perf.data
python2 report_html.py -i /tmp/perf.data -o /tmp/report.html
@@ -1,3 +0,0 @@
git clone https://android.googlesource.com/platform/prebuilts/simpleperf
git reset --hard 311a9d2cd27841498fc90a0b26a755deb47e7ebd
cp -r report_html.* simpleperf_report_lib.py utils.py inferno lib ~/one/external/simpleperf/
+1
View File
@@ -144,6 +144,7 @@ if __name__ == "__main__":
uds_client.write_data_by_identifier(VOLKSWAGEN_DATA_IDENTIFIER_TYPE.CODING, new_coding) # type: ignore
except (NegativeResponseError, MessageTimeoutError):
print("Writing new configuration failed!")
print("Make sure the comma processes are stopped: tmux kill-session -t comma")
quit()
try: