From 4e4248379a3c192ce654204f0f25daabeb60c8c4 Mon Sep 17 00:00:00 2001 From: dragonpilot Date: Fri, 28 Feb 2020 15:40:21 +1000 Subject: [PATCH] update shutdownd logic --- selfdrive/dragonpilot/shutdownd/shutdownd.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/selfdrive/dragonpilot/shutdownd/shutdownd.py b/selfdrive/dragonpilot/shutdownd/shutdownd.py index cc0b1bf45..a467415de 100644 --- a/selfdrive/dragonpilot/shutdownd/shutdownd.py +++ b/selfdrive/dragonpilot/shutdownd/shutdownd.py @@ -24,16 +24,14 @@ def main(gctx=None): with open("/sys/class/power_supply/usb/present") as f: usb_online = bool(int(f.read())) auto_shutdown_at = get_shutdown_val() + if not last_shutdown_val == auto_shutdown_at: + shutdown_count = 0 + last_shutdown_val = auto_shutdown_at - if started or usb_online: - shutdown_count = 0 + if not started and not usb_online: + shutdown_count += 1 else: - if not usb_online: - shutdown_count += 1 - - if not last_shutdown_val == auto_shutdown_at: shutdown_count = 0 - last_shutdown_val = auto_shutdown_at if auto_shutdown_at is None: auto_shutdown_at = get_shutdown_val()