From 916448af25d61a9acf1d35356fafccdfc800c440 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Fri, 29 May 2020 12:00:29 -0700 Subject: [PATCH] break canError into two separate events --- cereal | 2 +- selfdrive/controls/controlsd.py | 10 +++++++--- selfdrive/controls/lib/events.py | 13 ++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cereal b/cereal index c8be73d10..0adfc7e77 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit c8be73d10c957bff769998588595107d62e9e738 +Subproject commit 0adfc7e77efbf1ebc21bf2629a85d165b319b23e diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index c8ea55088..e3e502c1a 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -117,6 +117,7 @@ class Controls: self.v_cruise_kph_last = 0 self.mismatch_counter = 0 self.can_error_counter = 0 + self.consecutive_can_error_count = 0 self.last_blinker_frame = 0 self.saturated_count = 0 self.events_prev = [] @@ -188,8 +189,13 @@ class Controls: LaneChangeState.laneChangeFinishing]: self.events.add(EventName.laneChange) - if self.can_rcv_error: + if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): self.events.add(EventName.canError) + self.consecutive_can_error_count += 1 + else: + self.consecutive_can_error_count = 0 + if self.consecutive_can_error_count > 2 / DT_CTRL: + self.events.add(EventName.canErrorPersistent) if self.mismatch_counter >= 200: self.events.add(EventName.controlsMismatch) if not self.sm.alive['plan'] and self.sm.alive['pathPlan']: @@ -210,8 +216,6 @@ class Controls: self.events.add(EventName.radarFault) if self.sm['plan'].radarCanError: self.events.add(EventName.radarCanError) - if not CS.canValid and self.sm.frame > 5 / DT_CTRL: - self.events.add(EventName.canError) if log.HealthData.FaultType.relayMalfunction in self.sm['health'].faults: self.events.add(EventName.relayMalfunction) if self.sm['plan'].fcw: diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 5b2fdf6ad..bf2dcaf04 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -305,6 +305,14 @@ EVENTS = { Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), }, + EventName.canErrorPersistent: { + ET.PERMANENT: Alert( + "CAN Error: Check Connections", + "", + AlertStatus.normal, AlertSize.small, + Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), + }, + # ********** events only containing alerts that display while engaged ********** EventName.vehicleModelInvalid: { @@ -603,11 +611,6 @@ EVENTS = { EventName.canError: { ET.IMMEDIATE_DISABLE: ImmediateDisableAlert("CAN Error: Check Connections"), ET.NO_ENTRY: NoEntryAlert("CAN Error: Check Connections"), - ET.PERMANENT: Alert( - "CAN Error: Check Connections", - "", - AlertStatus.normal, AlertSize.small, - Priority.LOW, VisualAlert.none, AudibleAlert.none, 0., 0., .2), }, EventName.steerUnavailable: {