-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kia Sorento and future Multi-Car Support #346
Changes from 20 commits
bea839c
7376209
4314efa
3f3075e
95b7919
5e76750
c92c08f
26c36df
2ca147f
96f54e3
22688e0
07a8b3a
9c02498
87d7549
c4a6506
119f48d
3df5a09
9f1bba6
c08d305
d7ca4ce
bb27195
1fddd38
6b51095
e6b0432
ad17983
7980457
1d67a26
f4e8926
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import crcmod | ||
from selfdrive.car.hyundai.values import CHECKSUM | ||
|
||
hyundai_checksum = crcmod.mkCrcFun(0x11D, initCrc=0xFD, rev=False, xorOut=0xdf) | ||
|
||
def make_can_msg(addr, dat, alt): | ||
return [addr, 0, dat, alt] | ||
|
||
def create_lkas11(packer, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False): | ||
def create_lkas11(packer, car_fingerprint, apply_steer, steer_req, cnt, enabled, lkas11, hud_alert, keep_stock=False): | ||
values = { | ||
"CF_Lkas_Icon": 3 if enabled else 0, | ||
"CF_Lkas_LdwsSysState": lkas11["CF_Lkas_LdwsSysState"] if keep_stock else 1, | ||
"CF_Lkas_LdwsSysState": 3 if steer_req else 1, | ||
"CF_Lkas_SysWarning": hud_alert, | ||
"CF_Lkas_LdwsLHWarning": lkas11["CF_Lkas_LdwsLHWarning"] if keep_stock else 0, | ||
"CF_Lkas_LdwsRHWarning": lkas11["CF_Lkas_LdwsRHWarning"] if keep_stock else 0, | ||
"CF_Lkas_HbaLamp": lkas11["CF_Lkas_HbaLamp"] if keep_stock else 0, | ||
"CF_Lkas_FcwBasReq": lkas11["CF_Lkas_FcwBasReq"] if keep_stock else 0, | ||
"CR_Lkas_StrToqReq": apply_steer, | ||
"CF_Lkas_ActToi": steer_req, | ||
"CF_Lkas_ToiFlt": lkas11["CF_Lkas_ToiFlt"] if keep_stock else 0, | ||
"CF_Lkas_ToiFlt": 0, | ||
"CF_Lkas_HbaSysState": lkas11["CF_Lkas_HbaSysState"] if keep_stock else 1, | ||
"CF_Lkas_FcwOpt": lkas11["CF_Lkas_FcwOpt"] if keep_stock else 0, | ||
"CF_Lkas_HbaOpt": lkas11["CF_Lkas_HbaOpt"] if keep_stock else 3, | ||
|
@@ -30,9 +31,20 @@ def create_lkas11(packer, apply_steer, steer_req, cnt, enabled, lkas11, hud_aler | |
} | ||
|
||
dat = packer.make_can_msg("LKAS11", 0, values)[2] | ||
dat = dat[:6] + dat[7] | ||
checksum = hyundai_checksum(dat) | ||
|
||
# CRC Checksum as seen on 2019 Hyundai Santa Fe | ||
if CHECKSUM[car_fingerprint] == 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While that is true, it will be the opposite when multiple vehicles support that checksum. |
||
dat = dat[:6] + dat[7] | ||
checksum = hyundai_checksum(dat) | ||
# Checksum of first 6 Bytes, as seen on 2018 Kia Sorento | ||
if CHECKSUM[car_fingerprint] == 6: | ||
dat = [ord(i) for i in dat] | ||
checksum = sum(dat[:6]) % 256 | ||
# Checksum of first 6 Bytes and last Byte as seen on 2018 Kia Stinger | ||
if CHECKSUM[car_fingerprint] == 7: | ||
dat = [ord(i) for i in dat] | ||
checksum = (sum(dat[:6]) + dat[7]) % 256 | ||
|
||
values["CF_Lkas_Chksum"] = checksum | ||
|
||
return packer.make_can_msg("LKAS11", 0, values) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm... I think keep supporting the connection with camera on bus 1 will be hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to leave this as 2, and update locally, unless I can figure out a clean way of doing this (like I did for panda)
I will fix this for the PR