Only show update alert if updater failed once since reboot (#1078)

* Only show update alert if updater failed

* no negetive days in warning message

* Also increase failed count when no internet

* Only set count to zero on actual update

* First run always fails because IsOffroad is not set yet
pull/1079/head
Willem Melching 5 years ago committed by GitHub
parent 5bd9d49b29
commit a5bd1d2a88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      common/params.py
  2. 7
      selfdrive/thermald.py
  3. 5
      selfdrive/updated.py

@ -93,6 +93,7 @@ keys = {
"TermsVersion": [TxType.PERSISTENT], "TermsVersion": [TxType.PERSISTENT],
"TrainingVersion": [TxType.PERSISTENT], "TrainingVersion": [TxType.PERSISTENT],
"UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], "UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START],
"UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START],
"Version": [TxType.PERSISTENT], "Version": [TxType.PERSISTENT],
"Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], "Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],
"Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START], "Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START],

@ -272,13 +272,16 @@ def thermald_thread():
last_update = now last_update = now
dt = now - last_update dt = now - last_update
if dt.days > DAYS_NO_CONNECTIVITY_MAX: update_failed_count = params.get("UpdateFailedCount")
update_failed_count = 0 if update_failed_count is None else int(update_failed_count)
if dt.days > DAYS_NO_CONNECTIVITY_MAX and update_failed_count > 1:
if current_connectivity_alert != "expired": if current_connectivity_alert != "expired":
current_connectivity_alert = "expired" current_connectivity_alert = "expired"
params.delete("Offroad_ConnectivityNeededPrompt") params.delete("Offroad_ConnectivityNeededPrompt")
params.put("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"])) params.put("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"]))
elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT: elif dt.days > DAYS_NO_CONNECTIVITY_PROMPT:
remaining_time = str(DAYS_NO_CONNECTIVITY_MAX - dt.days) remaining_time = str(max(DAYS_NO_CONNECTIVITY_MAX - dt.days, 0))
if current_connectivity_alert != "prompt" + remaining_time: if current_connectivity_alert != "prompt" + remaining_time:
current_connectivity_alert = "prompt" + remaining_time current_connectivity_alert = "prompt" + remaining_time
alert_connectivity_prompt = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"]) alert_connectivity_prompt = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"])

@ -293,6 +293,7 @@ def attempt_update():
def main(gctx=None): def main(gctx=None):
update_failed_count = 0
overlay_init_done = False overlay_init_done = False
wait_helper = WaitTimeHelper() wait_helper = WaitTimeHelper()
params = Params() params = Params()
@ -312,6 +313,7 @@ def main(gctx=None):
raise RuntimeError("couldn't get overlay lock; is another updated running?") raise RuntimeError("couldn't get overlay lock; is another updated running?")
while True: while True:
update_failed_count += 1
time_wrong = datetime.datetime.now().year < 2019 time_wrong = datetime.datetime.now().year < 2019
ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "8.8.8.8"]) ping_failed = subprocess.call(["ping", "-W", "4", "-c", "1", "8.8.8.8"])
@ -335,6 +337,7 @@ def main(gctx=None):
if params.get("IsOffroad") == b"1": if params.get("IsOffroad") == b"1":
attempt_update() attempt_update()
update_failed_count = 0
else: else:
cloudlog.info("not running updater, openpilot running") cloudlog.info("not running updater, openpilot running")
@ -348,8 +351,8 @@ def main(gctx=None):
overlay_init_done = False overlay_init_done = False
except Exception: except Exception:
cloudlog.exception("uncaught updated exception, shouldn't happen") cloudlog.exception("uncaught updated exception, shouldn't happen")
overlay_init_done = False
params.put("UpdateFailedCount", str(update_failed_count))
wait_between_updates(wait_helper.ready_event) wait_between_updates(wait_helper.ready_event)
if wait_helper.shutdown: if wait_helper.shutdown:
break break

Loading…
Cancel
Save