kinda works

pull/28386/head
Shane Smiskol 2 years ago
parent 407d80552e
commit c9e3d0bf3c
  1. 54
      hkg_fuzzy_fp.py
  2. 4
      selfdrive/car/fw_query_definitions.py
  3. 10
      selfdrive/car/hyundai/values.py

@ -1,4 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import re
from cereal import car from cereal import car
from selfdrive.car.hyundai.values import FW_VERSIONS from selfdrive.car.hyundai.values import FW_VERSIONS
@ -14,9 +16,55 @@ platform_codes = set()
# these ecus are available on all cars (even CAN FD with no OBD fingerprinting) # these ecus are available on all cars (even CAN FD with no OBD fingerprinting)
fw_keys = [(Ecu.fwdCamera, 0x7c4, None), (Ecu.fwdRadar, 0x7d0, None)] fw_keys = [(Ecu.fwdCamera, 0x7c4, None), (Ecu.fwdRadar, 0x7d0, None)]
for car in FW_VERSIONS.keys(): # RADAR_REGEX = br'[A-Z]+|\S+'
# print() # RADAR_REGEX = br'(?=[A-Z][a-z]|_)'
# print(car) RADAR_REGEX = br'([A-Z]+[A-Z0-9]*)'
def get_platform_code(car_fw):
codes = list()
for fw in car_fw[(Ecu.fwdRadar, 0x7d0, None)]:
start_idx = fw.index(b'\xf1\x00')
fw = fw[start_idx + 2:]
# fw = fw.decode('utf-8', 'ignore')
# code, radar_code_variant = re.findall(RADAR_REGEX, fw)
code = re.match(RADAR_REGEX, fw).group(0)
radar_code_variant = fw[len(code):len(code) + 4 - len(code)].replace(b'_', b'')
# code, radar_code_variant = fw[:2], fw[2:4].replace(b"_", b"")
print(f"{code=}, {radar_code_variant=}, {fw=}")
continue
# code = ''
# radar_code_variant = ''
end_of_platform = False
for idx, char in enumerate(fw):
if char.islower():
end_of_platform = True
elif char in ['_']: # end of platform code
break
if not end_of_platform:
code += char
else:
if char == ' ':
break
radar_code_variant += char
print(f"{code=}, {radar_code_variant=}, {fw=}")
for car, car_fw in FW_VERSIONS.items():
print()
print(car)
# print(car, car_fw)
get_platform_code(car_fw)
continue
for ecu, fws in FW_VERSIONS[car].items(): for ecu, fws in FW_VERSIONS[car].items():
if ecu not in fw_keys: if ecu not in fw_keys:
continue continue

@ -2,7 +2,7 @@
import capnp import capnp
from dataclasses import dataclass, field from dataclasses import dataclass, field
import struct import struct
from typing import Dict, List, Optional, Tuple from typing import Callable, Dict, List, Optional, Tuple
import panda.python.uds as uds import panda.python.uds as uds
@ -67,3 +67,5 @@ class FwQueryConfig:
non_essential_ecus: Dict[capnp.lib.capnp._EnumModule, List[str]] = field(default_factory=dict) non_essential_ecus: Dict[capnp.lib.capnp._EnumModule, List[str]] = field(default_factory=dict)
# Ecus added for data collection, not to be fingerprinted on # Ecus added for data collection, not to be fingerprinted on
extra_ecus: List[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]]] = field(default_factory=list) extra_ecus: List[Tuple[capnp.lib.capnp._EnumModule, int, Optional[int]]] = field(default_factory=list)
# A function that each make can provide to fuzzy fingerprint reliably on that make
match_fw_to_car_fuzzy: Callable = None

@ -318,6 +318,11 @@ FINGERPRINTS = {
}], }],
} }
def hyundai_fuzzy_fingerprint(car_fw):
pass
HYUNDAI_VERSION_REQUEST_LONG = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ HYUNDAI_VERSION_REQUEST_LONG = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
p16(0xf100) # Long description p16(0xf100) # Long description
HYUNDAI_VERSION_REQUEST_MULTI = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \ HYUNDAI_VERSION_REQUEST_MULTI = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
@ -358,8 +363,11 @@ FW_QUERY_CONFIG = FwQueryConfig(
(Ecu.adas, 0x730, None), # ADAS Driving ECU on HDA2 platforms (Ecu.adas, 0x730, None), # ADAS Driving ECU on HDA2 platforms
(Ecu.cornerRadar, 0x7b7, None), (Ecu.cornerRadar, 0x7b7, None),
], ],
match_fw_to_car_fuzzy=hyundai_fuzzy_fingerprint,
) )
FW_VERSIONS = { FW_VERSIONS = {
CAR.IONIQ: { CAR.IONIQ: {
(Ecu.fwdRadar, 0x7d0, None): [ (Ecu.fwdRadar, 0x7d0, None): [
@ -1584,7 +1592,7 @@ HYBRID_CAR = {CAR.IONIQ_PHEV, CAR.ELANTRA_HEV_2021, CAR.KIA_NIRO_PHEV, CAR.KIA_N
EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR.KONA_EV_2022, CAR.KIA_EV6, CAR.IONIQ_5, CAR.GENESIS_GV60_EV_1ST_GEN} EV_CAR = {CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.KONA_EV, CAR.KIA_NIRO_EV, CAR.KONA_EV_2022, CAR.KIA_EV6, CAR.IONIQ_5, CAR.GENESIS_GV60_EV_1ST_GEN}
# these cars require a special panda safety mode due to missing counters and checksums in the messages # these cars require a special panda safety mode due to missing counters and checksums in the messages
LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_EV_2020, CAR.IONIQ_EV_LTD, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022} LEGACY_SAFETY_MODE_CAR = {CAR.HYUNDAI_GENESIS, CAR.IONIQ_PHEV, CAR.IONIQ, CAR.KONA_EV, CAR.KIA_SORENTO, CAR.SONATA_LF, CAR.KIA_OPTIMA_G4, CAR.KIA_OPTIMA_G4_FL, CAR.VELOSTER, CAR.KIA_STINGER, CAR.GENESIS_G70, CAR.GENESIS_G80, CAR.KIA_CEED, CAR.ELANTRA, CAR.IONIQ_HEV_2022}
# If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points. # If 0x500 is present on bus 1 it probably has a Mando radar outputting radar points.
# If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py # If no points are outputted by default it might be possible to turn it on using selfdrive/debug/hyundai_enable_radar_points.py

Loading…
Cancel
Save