Skip to content

Commit

Permalink
Subaru FPv2 support (commaai#1878)
Browse files Browse the repository at this point in the history
* Add Subaru FPv2 support

* Add Subaru Ascent and Impreza FPv2 values

* Remove 10 second delay, use UDS for Subaru FPv2

* before VW

* before hyundai

Co-authored-by: Willem Melching <[email protected]>
  • Loading branch information
martinl and pd0wm authored Jan 4, 2022
1 parent 1ca5e1c commit 6b20534
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
13 changes: 13 additions & 0 deletions selfdrive/car/fw_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,21 @@ def p16(val):

NISSAN_RX_OFFSET = 0x20

SUBARU_VERSION_REQUEST = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER]) + \
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION)
SUBARU_VERSION_RESPONSE = bytes([uds.SERVICE_TYPE.READ_DATA_BY_IDENTIFIER + 0x40]) + \
p16(uds.DATA_IDENTIFIER_TYPE.APPLICATION_DATA_IDENTIFICATION)


# brand, request, response, response offset
REQUESTS = [
# Subaru
(
"subaru",
[TESTER_PRESENT_REQUEST, SUBARU_VERSION_REQUEST],
[TESTER_PRESENT_RESPONSE, SUBARU_VERSION_RESPONSE],
DEFAULT_RX_OFFSET,
),
# Hyundai
(
"hyundai",
Expand Down
47 changes: 47 additions & 0 deletions selfdrive/car/subaru/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,53 @@ class CAR:
}],
}

FW_VERSIONS = {
CAR.ASCENT: {
# 2019 Ascent UDM
# Ecu, addr, subaddr: ROM ID
(Ecu.esp, 0x7b0, None): [
b'\xa5 \x19\x02\x00',
],
(Ecu.eps, 0x746, None): [
b'\x85\xc0\xd0\x00',
],
(Ecu.fwdCamera, 0x787, None): [
b'\x00\x00d\xb9\x1f@ \x10',
],
(Ecu.engine, 0x7e0, None): [
b'\xbb,\xa0t\a',
],
(Ecu.transmission, 0x7e1, None): [
b'\x00\xfe\xf7\x00\x00',
],
},
CAR.IMPREZA: {
# 2018 Crosstrek EDM
# 2018 Impreza ADM
# Ecu, addr, subaddr: ROM ID
(Ecu.esp, 0x7b0, None): [
b'\x7a\x94\x3f\x90\x00',
b'\xa2 \x185\x00',
],
(Ecu.eps, 0x746, None): [
b'\x7a\xc0\x0c\x00',
b'z\xc0\b\x00',
],
(Ecu.fwdCamera, 0x787, None): [
b'\x00\x00\x64\xb5\x1f\x40\x20\x0e',
b'\x00\x00d\xdc\x1f@ \x0e',
],
(Ecu.engine, 0x7e0, None): [
b'\xaa\x61\x66\x73\x07',
b'\xbeacr\a',
],
(Ecu.transmission, 0x7e1, None): [
b'\xe3\xe5\x46\x31\x00',
b'\xe4\xe5\x061\x00',
],
},
}

STEER_THRESHOLD = {
CAR.ASCENT: 80,
CAR.IMPREZA: 80,
Expand Down

0 comments on commit 6b20534

Please sign in to comment.