openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

#!/usr/bin/env python3
2 years ago
import re
from cereal import car
from selfdrive.car.hyundai.values import FW_VERSIONS
Ecu = car.CarParams.Ecu
platform_codes = set()
# these ecus are available on all cars (even CAN FD with no OBD fingerprinting)
fw_keys = [(Ecu.fwdCamera, 0x7c4, None), (Ecu.fwdRadar, 0x7d0, None)]
2 years ago
RADAR_REGEX = br'([A-Z]+[A-Z0-9]*)'
2 years ago
def get_platform_codes(car_fw):
2 years ago
radar_codes = set()
camera_codes = set()
2 years ago
for fw in car_fw[(Ecu.fwdRadar, 0x7d0, None)]:
start_idx = fw.index(b'\xf1\x00')
2 years ago
fw = fw[start_idx + 2:][:4]
2 years ago
2 years ago
# code = re.match(RADAR_REGEX, fw).group(0) # TODO: check NONE, or have a test
# radar_code_variant = fw[len(code):4].replace(b'_', b'').replace(b' ', b'')
2 years ago
2 years ago
radar_code = fw[:4].replace(b" ", b"").replace(b"_", b"")
2 years ago
2 years ago
radar_codes.add(radar_code)
# codes.add((code, radar_code_variant))
for fw in car_fw[(Ecu.fwdCamera, 0x7c4, None)]:
start_idx = fw.index(b'\xf1\x00')
fw = fw[start_idx + 2:][:4]
# code = re.match(RADAR_REGEX, fw).group(0) # TODO: check NONE, or have a test
# radar_code_variant = fw[len(code):4].replace(b'_', b'').replace(b' ', b'')
radar_code = fw[:4].replace(b" ", b"").replace(b"_", b"")
camera_codes.add(radar_code)
# codes.add((code, radar_code_variant))
return radar_codes, camera_codes
# return codes
2 years ago
for car, car_fw in FW_VERSIONS.items():
2 years ago
radar_codes, camera_codes = get_platform_codes(car_fw)
print(f"{car:36}: radar: {radar_codes}, camera: {camera_codes}")