Skip to content

Commit

Permalink
espActive to CarState and CarEvent.EventName
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyhaibin committed Jun 13, 2024
1 parent 1a083c2 commit 18f4c7b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
paramsdTemporaryError @50;
paramsdPermanentError @119;
actuatorsApiUnavailable @120;
espActive @121;

radarCanErrorDEPRECATED @15;
communityFeatureDisallowedDEPRECATED @62;
Expand Down Expand Up @@ -194,6 +195,7 @@ struct CarState {
espDisabled @32 :Bool;
accFaulted @42 :Bool;
carFaultedNonCritical @47 :Bool; # some ECU is faulted, but car remains controllable
espActive @44 :Bool;

# cruise state
cruiseState @10 :CruiseState;
Expand Down
5 changes: 2 additions & 3 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,8 @@ def update(self, cp, cp_cam):
ret.brakeHoldActive = cp.vl["TCS15"]["AVH_LAMP"] == 2 # 0 OFF, 1 ERROR, 2 ACTIVE, 3 READY
ret.parkingBrake = cp.vl["TCS13"]["PBRAKE_ACT"] == 1
ret.espDisabled = cp.vl["TCS11"]["TCS_PAS"] == 1
# TCS13|ACCEnable: 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED
# TCS11|ABS_ACT: 1 ABS ACTIVE
ret.accFaulted = cp.vl["TCS13"]["ACCEnable"] != 0 or cp.vl["TCS11"]["ABS_ACT"] != 0
ret.accFaulted = cp.vl["TCS13"]["ACCEnable"] != 0 # 0 ACC CONTROL ENABLED, 1-3 ACC CONTROL DISABLED
ret.espActive = cp.vl["TCS11"]["ABS_ACT"] != 0 # 1 ESP ACTIVE

if self.CP.flags & (HyundaiFlags.HYBRID | HyundaiFlags.EV):
if self.CP.flags & HyundaiFlags.HYBRID:
Expand Down
2 changes: 2 additions & 0 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_
events.add(EventName.wrongCarMode)
if cs_out.espDisabled:
events.add(EventName.espDisabled)
if cs_out.espActive:
events.add(EventName.espActive)
if cs_out.stockFcw:
events.add(EventName.stockFcw)
if cs_out.stockAeb:
Expand Down
5 changes: 5 additions & 0 deletions selfdrive/controls/lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,11 @@ def joystick_alert(CP: car.CarParams, CS: car.CarState, sm: messaging.SubMaster,
ET.NO_ENTRY: NoEntryAlert("Cruise Fault: Restart the Car"),
},

EventName.espActive: {
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Electronic Stability Control Active"),
ET.NO_ENTRY: NoEntryAlert("Electronic Stability Control Active"),
},

EventName.controlsMismatch: {
ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("Controls Mismatch"),
ET.NO_ENTRY: NoEntryAlert("Controls Mismatch"),
Expand Down

0 comments on commit 18f4c7b

Please sign in to comment.