diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 4bb4877741..e2134e55d9 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -121,6 +121,7 @@ class Controls: self.last_blinker_frame = 0 self.saturated_count = 0 self.distance_traveled = 0 + self.last_functional_fan_frame = 0 self.events_prev = [] self.current_alert_types = [ET.PERMANENT] @@ -171,6 +172,14 @@ class Controls: if self.sm['thermal'].memUsedPercent > 90: self.events.add(EventName.lowMemory) + # Alert if fan isn't spinning for 5 seconds + if self.sm['health'].hwType in [HwType.uno, HwType.dos]: + if self.sm['health'].fanSpeedRpm == 0 and self.sm['thermal'].fanSpeed > 50: + if (self.sm.frame - self.last_functional_fan_frame) * DT_CTRL > 5.0: + self.events.add(EventName.fanMalfunction) + else: + self.last_functional_fan_frame = self.sm.frame + # Handle calibration status cal_status = self.sm['liveCalibration'].calStatus if cal_status != Calibration.CALIBRATED: diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index a848a47c72..b3a5f19a33 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -211,8 +211,6 @@ def wrong_car_mode_alert(CP: car.CarParams, sm: messaging.SubMaster, metric: boo EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, bool], Alert]]]] = { # ********** events with no alerts ********** - EventName.fanMalfunction: {}, - # ********** events only containing alerts displayed in all states ********** EventName.debugAlert: { @@ -471,6 +469,14 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.), }, + EventName.fanMalfunction: { + ET.PERMANENT: Alert( + "Fan Malfunction", + "Contact Support", + AlertStatus.normal, AlertSize.mid, + Priority.LOWER, VisualAlert.none, AudibleAlert.none, 0., 0., .2) + }, + # ********** events that affect controls state transitions ********** EventName.pcmEnable: {