From c742d425f185540392896ec2db3b22929a5ecb5f Mon Sep 17 00:00:00 2001 From: Jason Wen Date: Tue, 26 Nov 2024 16:43:44 -0500 Subject: [PATCH] Hyundai CAN: Explicitly parse gear shifter values for `EV, HEV, PHEV` --- opendbc/car/hyundai/carstate.py | 4 +++- opendbc/dbc/hyundai_kia_generic.dbc | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/opendbc/car/hyundai/carstate.py b/opendbc/car/hyundai/carstate.py index 8e32a91c0a..9191af4a09 100644 --- a/opendbc/car/hyundai/carstate.py +++ b/opendbc/car/hyundai/carstate.py @@ -34,11 +34,13 @@ def __init__(self, CP): "GEAR_SHIFTER" if CP.flags & HyundaiFlags.CANFD: self.shifter_values = can_define.dv[self.gear_msg_canfd]["GEAR"] + elif CP.flags & (HyundaiFlags.HYBRID | HyundaiFlags.EV): + self.shifter_values = can_define.dv["ELECT_GEAR"]["Elect_Gear_Shifter"] elif self.CP.flags & HyundaiFlags.CLUSTER_GEARS: self.shifter_values = can_define.dv["CLU15"]["CF_Clu_Gear"] elif self.CP.flags & HyundaiFlags.TCU_GEARS: self.shifter_values = can_define.dv["TCU12"]["CUR_GR"] - else: # preferred and elect gear methods use same definition + else: self.shifter_values = can_define.dv["LVR12"]["CF_Lvr_Gear"] self.accelerator_msg_canfd = "ACCELERATOR" if CP.flags & HyundaiFlags.EV else \ diff --git a/opendbc/dbc/hyundai_kia_generic.dbc b/opendbc/dbc/hyundai_kia_generic.dbc index c828d33c2f..0ad95f10e1 100644 --- a/opendbc/dbc/hyundai_kia_generic.dbc +++ b/opendbc/dbc/hyundai_kia_generic.dbc @@ -112,7 +112,7 @@ BO_ 1265 CLU11: 4 CLU BO_ 1260 Sign_Detection: 8 XXX SG_ SpeedLim_Nav_Cam : 40|8@1+ (1,0) [0|255] "km/h / mph" XXX SG_ SpeedLim_Nav_Cam2 : 48|8@1+ (1,0) [0|255] "km/h / mph" XXX - + BO_ 1492 TMU_GW_PE_01: 8 CLU SG_ TMU_IVRActivity : 0|2@1+ (1.0,0.0) [0.0|3.0] "" DATC SG_ TMU_PhoneActivity : 2|2@1+ (1.0,0.0) [0.0|3.0] "" DATC @@ -1661,7 +1661,7 @@ VAL_ 274 CUR_GR 1 "D" 2 "D" 3 "D" 4 "D" 5 "D" 6 "D" 7 "D" 8 "D" 14 "R" 0 "P"; VAL_ 512 HYDROGEN_GEAR_SHIFTER 5 "D" 8 "S" 6 "N" 7 "R" 0 "P"; VAL_ 871 CF_Lvr_IsgState 0 "enabled" 1 "activated" 2 "unknown" 3 "disabled"; VAL_ 871 CF_Lvr_Gear 12 "T" 5 "D" 8 "S" 6 "N" 7 "R" 0 "P"; -VAL_ 882 Elect_Gear_Shifter 5 "D" 8 "S" 6 "N" 7 "R" 0 "P"; +VAL_ 882 Elect_Gear_Shifter 4 "S" 5 "D" 8 "S" 6 "N" 7 "R" 0 "P"; VAL_ 905 ACCMode 0 "off" 1 "enabled" 2 "driver_override" 3 "off_maybe_fault" 4 "cancelled"; VAL_ 909 CF_VSM_Warn 2 "FCW" 3 "AEB"; VAL_ 916 ACCEnable 0 "SCC ready" 1 "SCC temp fault" 2 "SCC permanent fault" 3 "SCC permanent fault, communication issue";