From 002683afabba597fefd69a9044a9cd84f65b8082 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Tue, 2 May 2023 15:50:17 -0700 Subject: [PATCH] boardd: reconnect when comms not healthy (#28075) * boardd: reconnect when comms not healthy * update comments * fix old-commit-hash: eb5ad17f8ea198d7268fdb0e836f2d2cfe9cae4d --- selfdrive/boardd/boardd.cc | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/selfdrive/boardd/boardd.cc b/selfdrive/boardd/boardd.cc index e56e1c2175..8694f6dea7 100644 --- a/selfdrive/boardd/boardd.cc +++ b/selfdrive/boardd/boardd.cc @@ -483,12 +483,26 @@ void panda_state_thread(PubMaster *pm, std::vector pandas, bool spoofin ignition = *ignition_opt; - // TODO: make this check fast, currently takes 16ms - // check if we have new pandas and are offroad - if (!ignition && (pandas.size() != Panda::list().size())) { - LOGW("Reconnecting to changed amount of pandas!"); - do_exit = true; - break; + // check if we should have pandad reconnect + if (!ignition) { + bool comms_healthy = true; + for (const auto &panda : pandas) { + comms_healthy &= panda->comms_healthy(); + } + + if (!comms_healthy) { + LOGE("Reconnecting, communication to pandas not healthy"); + do_exit = true; + + // TODO: list is slow, takes 16ms + } else if (pandas.size() != Panda::list().size()) { + LOGW("Reconnecting to changed amount of pandas!"); + do_exit = true; + } + + if (do_exit) { + break; + } } // clear ignition-based params and set new safety on car start