diff --git a/cereal b/cereal index dbdab72167..9c23923d48 160000 --- a/cereal +++ b/cereal @@ -1 +1 @@ -Subproject commit dbdab72167c83ee12968e44df646436bd0a4727e +Subproject commit 9c23923d4840c622d88c0408f72776db363dd22f diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 595cb47b37..6cd5060b11 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -23,7 +23,7 @@ from selfdrive.controls.lib.events import Events, ET from selfdrive.controls.lib.alertmanager import AlertManager from selfdrive.controls.lib.vehicle_model import VehicleModel from selfdrive.locationd.calibrationd import Calibration -from selfdrive.hardware import HARDWARE, TICI +from selfdrive.hardware import HARDWARE, TICI, EON from selfdrive.manager.process_config import managed_processes LDW_MIN_SPEED = 31 * CV.MPH_TO_MS @@ -201,6 +201,9 @@ class Controls: # TODO: make tici threshold the same if self.sm['deviceState'].memoryUsagePercent > (90 if TICI else 65) and not SIMULATION: self.events.add(EventName.lowMemory) + cpus = list(self.sm['deviceState'].cpuUsagePercent)[:(-1 if EON else None)] + if max(cpus, default=0) > 95: + self.events.add(EventName.highCpuUsage) # Alert if fan isn't spinning for 5 seconds if self.sm['pandaState'].pandaType in [PandaType.uno, PandaType.dos]: diff --git a/selfdrive/controls/lib/events.py b/selfdrive/controls/lib/events.py index 6908549cf1..6a02ff23eb 100644 --- a/selfdrive/controls/lib/events.py +++ b/selfdrive/controls/lib/events.py @@ -729,7 +729,14 @@ EVENTS: Dict[int, Dict[str, Union[Alert, Callable[[Any, messaging.SubMaster, boo ET.SOFT_DISABLE: SoftDisableAlert("Low Memory: Reboot Your Device"), ET.PERMANENT: NormalPermanentAlert("Low Memory", "Reboot your Device"), ET.NO_ENTRY: NoEntryAlert("Low Memory: Reboot Your Device", - audible_alert=AudibleAlert.chimeDisengage), + audible_alert=AudibleAlert.chimeDisengage), + }, + + EventName.highCpuUsage: { + #ET.SOFT_DISABLE: SoftDisableAlert("System Malfunction: Reboot Your Device"), + #ET.PERMANENT: NormalPermanentAlert("System Malfunction", "Reboot your Device"), + ET.NO_ENTRY: NoEntryAlert("System Malfunction: Reboot Your Device", + audible_alert=AudibleAlert.chimeDisengage), }, EventName.accFaulted: { diff --git a/selfdrive/thermald/thermald.py b/selfdrive/thermald/thermald.py index bcd3f18883..dac7b4e8fa 100755 --- a/selfdrive/thermald/thermald.py +++ b/selfdrive/thermald/thermald.py @@ -259,7 +259,7 @@ def thermald_thread(): msg.deviceState.freeSpacePercent = get_available_percent(default=100.0) msg.deviceState.memoryUsagePercent = int(round(psutil.virtual_memory().percent)) - msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent())) + msg.deviceState.cpuUsagePercent = [int(round(n)) for n in psutil.cpu_percent(percpu=True)] msg.deviceState.gpuUsagePercent = int(round(HARDWARE.get_gpu_usage_percent())) msg.deviceState.networkType = network_type msg.deviceState.networkStrength = network_strength