Hyundai fw query (#1540)

* hyundai fw query

* Change query

* this works

* That is not engine

* hyundai fw query

* Change query

* this works

* That is not engine

* Skip FW query in test_car_models

* Those routes don't fingerprint properly after speedup

* only send toyota queries to subaddresses

Co-authored-by: openpilot laptop <laptop@comma.ai>
pull/1530/head
Willem Melching 2020-05-19 13:43:44 -07:00 committed by GitHub
parent 58d8887328
commit bb8bbdd9ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 6 deletions

View File

@ -77,8 +77,9 @@ def only_toyota_left(candidate_cars):
# **** for use live only ****
def fingerprint(logcan, sendcan, has_relay):
fixed_fingerprint = os.environ.get('FINGERPRINT', "")
skip_fw_query = os.environ.get('SKIP_FW_QUERY', False)
if has_relay and not fixed_fingerprint:
if has_relay and not fixed_fingerprint and not skip_fw_query:
# Vin query only reliably works thorugh OBDII
bus = 1

View File

@ -12,9 +12,11 @@ import panda.python.uds as uds
from cereal import car
Ecu = car.CarParams.Ecu
def p16(val):
return struct.pack("!H", val)
TESTER_PRESENT_REQUEST = bytes([uds.SERVICE_TYPE.TESTER_PRESENT, 0x0])
TESTER_PRESENT_RESPONSE = bytes([uds.SERVICE_TYPE.TESTER_PRESENT + 0x40, 0x0])
@ -36,6 +38,13 @@ UDS_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
UDS_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION)
HYUNDAI_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
p16(uds.DATA_IDENTIFIER_TYPE.VEHICLE_MANUFACTURER_SPARE_PART_NUMBER) + \
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_SOFTWARE_IDENTIFICATION) + \
p16(0xf1a0) # 4 Byte version number
HYUNDAI_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40])
TOYOTA_VERSION_REQUEST = b'\x1a\x88\x01'
TOYOTA_VERSION_RESPONSE = b'\x5a\x88\x01'
@ -43,24 +52,35 @@ OBD_VERSION_REQUEST = b'\x09\x04'
OBD_VERSION_RESPONSE = b'\x49\x04'
# supports subaddressing, request, response
REQUESTS = [
# Hundai
(
False,
[HYUNDAI_VERSION_REQUEST],
[HYUNDAI_VERSION_RESPONSE],
),
# Honda
(
False,
[UDS_VERSION_REQUEST],
[UDS_VERSION_RESPONSE]
[UDS_VERSION_RESPONSE],
),
# Toyota
(
True,
[SHORT_TESTER_PRESENT_REQUEST, TOYOTA_VERSION_REQUEST],
[SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE]
[SHORT_TESTER_PRESENT_RESPONSE, TOYOTA_VERSION_RESPONSE],
),
(
True,
[SHORT_TESTER_PRESENT_REQUEST, OBD_VERSION_REQUEST],
[SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE]
[SHORT_TESTER_PRESENT_RESPONSE, OBD_VERSION_RESPONSE],
),
(
True,
[TESTER_PRESENT_REQUEST, DEFAULT_DIAGNOSTIC_REQUEST, EXTENDED_DIAGNOSTIC_REQUEST, UDS_VERSION_REQUEST],
[TESTER_PRESENT_RESPONSE, DEFAULT_DIAGNOSTIC_RESPONSE, EXTENDED_DIAGNOSTIC_RESPONSE, UDS_VERSION_RESPONSE]
[TESTER_PRESENT_RESPONSE, DEFAULT_DIAGNOSTIC_RESPONSE, EXTENDED_DIAGNOSTIC_RESPONSE, UDS_VERSION_RESPONSE],
)
]
@ -134,8 +154,12 @@ def get_fw_versions(logcan, sendcan, bus, extra=None, timeout=0.1, debug=False,
fw_versions = {}
for i, addr in enumerate(tqdm(addrs, disable=not progress)):
for addr_chunk in chunks(addr):
for request, response in REQUESTS:
for supports_sub_addr, request, response in REQUESTS:
try:
# Don't send Hyundai and Honda requests to subaddress
if i != 0 and not supports_sub_addr:
continue
query = IsoTpParallelQuery(sendcan, logcan, bus, addr_chunk, request, response, debug=debug)
t = 2 * timeout if i == 0 else timeout
fw_versions.update(query.get_data(t))

View File

@ -135,6 +135,16 @@ ECU_FINGERPRINT = {
Ecu.fwdCamera: [832, 1156, 1191, 1342]
}
FW_VERSIONS = {
CAR.SONATA: {
(Ecu.esp, 0x7d1, None): [b'\xf1\x8758910-L0100\xf1\xa01.04'],
(Ecu.engine, 0x7e0, None): [b'\xf1\x87391162M003\xf1\xa0000F'],
(Ecu.eps, 0x7d4, None): [b'\xf1\x8756310L0010\x00\xf1\xa01.01'],
(Ecu.fwdRadar, 0x7d0, None): [b'\xf1\x8799110L0000\xf1\xa01.00'],
(Ecu.transmission, 0x7e1, None): [b'U903\x00\x00\x00\x00\x00\x00'],
}
}
CHECKSUM = {
"crc8": [CAR.SANTA_FE, CAR.SONATA, CAR.PALISADE],
"6B": [CAR.KIA_SORENTO, CAR.HYUNDAI_GENESIS],

View File

@ -247,6 +247,7 @@ routes = {
'enableCamera': True,
'enableDsu': True,
'enableGasInterceptor': False,
'fingerprintSource': 'fixed',
},
"cdf2f7de565d40ae|2019-04-25--03-53-41": {
'carFingerprint': TOYOTA.RAV4_TSS2,
@ -296,6 +297,7 @@ routes = {
"01b22eb2ed121565|2020-02-02--11-25-51": {
'carFingerprint': TOYOTA.LEXUS_RX_TSS2,
'enableCamera': True,
'fingerprintSource': 'fixed',
},
"ec429c0f37564e3c|2020-02-01--17-28-12": {
'carFingerprint': TOYOTA.LEXUS_NXH,
@ -426,6 +428,7 @@ if __name__ == "__main__":
params.put("CommunityFeaturesToggle", "1")
params.put("Passive", "1" if route in passive_routes else "0")
os.environ['SKIP_FW_QUERY'] = "1"
if checks.get('fingerprintSource', None) == 'fixed':
os.environ['FINGERPRINT'] = checks['carFingerprint']
else: