diff --git a/common/params.py b/common/params.py index 009e5729db..cac1cff40f 100755 --- a/common/params.py +++ b/common/params.py @@ -93,6 +93,7 @@ keys = { "TermsVersion": [TxType.PERSISTENT], "TrainingVersion": [TxType.PERSISTENT], "UpdateAvailable": [TxType.CLEAR_ON_MANAGER_START], + "UpdateFailedCount": [TxType.CLEAR_ON_MANAGER_START], "Version": [TxType.PERSISTENT], "Offroad_ChargeDisabled": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT], "Offroad_ConnectivityNeeded": [TxType.CLEAR_ON_MANAGER_START], diff --git a/selfdrive/thermald.py b/selfdrive/thermald.py index cfd366dc95..ad54d1e30a 100755 --- a/selfdrive/thermald.py +++ b/selfdrive/thermald.py @@ -272,13 +272,16 @@ def thermald_thread(): last_update = now 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": current_connectivity_alert = "expired" params.delete("Offroad_ConnectivityNeededPrompt") params.put("Offroad_ConnectivityNeeded", json.dumps(OFFROAD_ALERTS["Offroad_ConnectivityNeeded"])) 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: current_connectivity_alert = "prompt" + remaining_time alert_connectivity_prompt = copy.copy(OFFROAD_ALERTS["Offroad_ConnectivityNeededPrompt"]) diff --git a/selfdrive/updated.py b/selfdrive/updated.py index efde9adcc8..29847fdb8b 100755 --- a/selfdrive/updated.py +++ b/selfdrive/updated.py @@ -293,6 +293,7 @@ def attempt_update(): def main(gctx=None): + update_failed_count = 0 overlay_init_done = False wait_helper = WaitTimeHelper() params = Params() @@ -312,6 +313,7 @@ def main(gctx=None): raise RuntimeError("couldn't get overlay lock; is another updated running?") while True: + update_failed_count += 1 time_wrong = datetime.datetime.now().year < 2019 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": attempt_update() + update_failed_count = 0 else: cloudlog.info("not running updater, openpilot running") @@ -348,8 +351,8 @@ def main(gctx=None): overlay_init_done = False except Exception: 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) if wait_helper.shutdown: break