From e3d92dc714689a8ffffb1e0a751da93bc79766b4 Mon Sep 17 00:00:00 2001 From: Willem Melching Date: Wed, 17 Mar 2021 14:20:05 +0100 Subject: [PATCH] verify safetyParam read back from PandaState (#20384) * verify safetyParam read back from PandaState * update ref * bump panda old-commit-hash: 3c23226edc2d328c489cc01a0950e6e4748d26a1 --- panda | 2 +- selfdrive/boardd/boardd.cc | 1 + selfdrive/boardd/panda.h | 1 + selfdrive/controls/controlsd.py | 6 ++++-- selfdrive/test/process_replay/ref_commit | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/panda b/panda index 3bb0408ee6..a32959accc 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 3bb0408ee62a983d54f9eab78c13cc1ee54703f4 +Subproject commit a32959accc12de3462e7446fd41e7dd79f6a9ec0 diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index 5060d81baf..abeac30b34 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -371,6 +371,7 @@ void panda_state_thread(bool spoofing_started) { ps.setPandaType(panda->hw_type); ps.setUsbPowerMode(cereal::PandaState::UsbPowerMode(pandaState.usb_power_mode)); ps.setSafetyModel(cereal::CarParams::SafetyModel(pandaState.safety_model)); + ps.setSafetyParam(pandaState.safety_param); ps.setFanSpeedRpm(fan_speed_rpm); ps.setFaultStatus(cereal::PandaState::FaultStatus(pandaState.fault_status)); ps.setPowerSaveEnabled((bool)(pandaState.power_save_enabled)); diff --git a/selfdrive/boardd/panda.h b/selfdrive/boardd/panda.h index d6abf1f6e2..d34a01c9bc 100644 --- a/selfdrive/boardd/panda.h +++ b/selfdrive/boardd/panda.h @@ -33,6 +33,7 @@ struct __attribute__((packed)) health_t { uint8_t car_harness_status; uint8_t usb_power_mode; uint8_t safety_model; + int16_t safety_param; uint8_t fault_status; uint8_t power_save_enabled; }; diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 62b4e0f8a7..e35c71c3a8 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -207,8 +207,10 @@ class Controls: if self.can_rcv_error or (not CS.canValid and self.sm.frame > 5 / DT_CTRL): self.events.add(EventName.canError) - if (self.sm['pandaState'].safetyModel != self.CP.safetyModel and self.sm.frame > 2 / DT_CTRL) or \ - self.mismatch_counter >= 200: + + safety_mismatch = self.sm['pandaState'].safetyModel != self.CP.safetyModel + safety_mismatch = safety_mismatch or self.sm['pandaState'].safetyParam != self.CP.safetyParam + if (safety_mismatch and self.sm.frame > 2 / DT_CTRL) or self.mismatch_counter >= 200: self.events.add(EventName.controlsMismatch) if not self.sm['liveParameters'].valid: diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index cbc93dc6ab..7d815a9aa2 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -68856f382a9bc423ad6997b2fe0d584ba4edb4ae \ No newline at end of file +f7af4a6523a7afa631460f5168646ca32c8fa4b3 \ No newline at end of file