From 21d3fd338591034b9a068d4dec192a022a0c2188 Mon Sep 17 00:00:00 2001 From: DevTekVE Date: Sat, 8 Jun 2024 21:59:31 +0200 Subject: [PATCH] Add logging for Sunnylink offline issue The code updates include error logging for debugging when Sunnylink goes offline. Log includes information such as the last ping time and the current time to better understand the cause of possible issues. This logging will aid in resolving status discrepancies with the Sunnylink feature. --- selfdrive/ui/qt/sidebar.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/selfdrive/ui/qt/sidebar.cc b/selfdrive/ui/qt/sidebar.cc index df9ebc45c0..171058b48f 100644 --- a/selfdrive/ui/qt/sidebar.cc +++ b/selfdrive/ui/qt/sidebar.cc @@ -3,6 +3,7 @@ #include #include +#include #include "selfdrive/ui/qt/util.h" #include "common/params.h" @@ -156,16 +157,21 @@ void Sidebar::updateState(const UIState &s) { ItemStatus sunnylinkStatus; auto last_sunnylink_ping = std::strtol(params.get("LastSunnylinkPingTime").c_str(), nullptr, 10); + auto current_nanos = nanos_since_boot(); + auto elapsed_sunnylink_ping = current_nanos - last_sunnylink_ping; auto sunnylink_enabled = params.getBool("SunnylinkEnabled"); if (!sunnylink_enabled) { sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("DISABLED")}, disabled_color}; - } else if (last_ping == 0) { + } else if (last_sunnylink_ping == 0) { sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("OFFLINE")}, warning_color}; } else { - if (nanos_since_boot() - last_sunnylink_ping < 80e9) + if (static_cast(elapsed_sunnylink_ping) < 80e9) { sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ONLINE")}, good_color}; - else + } + else { + LOGE("Sunnylink is offline, last ping: [%ld]. Current time: [%ld], diff: [%ld]", last_sunnylink_ping, current_nanos, elapsed_sunnylink_ping); sunnylinkStatus = ItemStatus{{tr("SUNNYLINK"), tr("ERROR")}, danger_color}; + } } setProperty("sunnylinkStatus", QVariant::fromValue(sunnylinkStatus)); }