From e3ffa91d177d5e9ec8c9735a489b582e71a96e74 Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Thu, 24 Dec 2020 19:01:53 +0800 Subject: [PATCH] simpilify ui_read_params (#19585) * simpilify ui_read_params * apply review --- selfdrive/ui/ui.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/selfdrive/ui/ui.cc b/selfdrive/ui/ui.cc index 5c0adc1828..bbf45d7917 100644 --- a/selfdrive/ui/ui.cc +++ b/selfdrive/ui/ui.cc @@ -243,14 +243,10 @@ static void ui_read_params(UIState *s) { if (frame % (5*UI_FREQ) == 0) { read_param(&s->is_metric, "IsMetric"); } else if (frame % (6*UI_FREQ) == 0) { - uint64_t last_athena_ping = 0; - int param_read = read_param(&last_athena_ping, "LastAthenaPingTime"); - if (param_read != 0) { // Failed to read param - s->scene.athenaStatus = NET_DISCONNECTED; - } else if (nanos_since_boot() - last_athena_ping < 70e9) { - s->scene.athenaStatus = NET_CONNECTED; - } else { - s->scene.athenaStatus = NET_ERROR; + s->scene.athenaStatus = NET_DISCONNECTED; + uint64_t last_ping = 0; + if (read_param(&last_ping, "LastAthenaPingTime") == 0) { + s->scene.athenaStatus = nanos_since_boot() - last_ping < 70e9 ? NET_CONNECTED : NET_ERROR; } } }