From a551df3132731bb7fb57e7637f0dda9985474485 Mon Sep 17 00:00:00 2001 From: Vasily Tarasov Date: Tue, 25 Sep 2018 20:29:01 -0700 Subject: [PATCH] GM: Ignore resume button until first engaged with set --- selfdrive/car/gm/interface.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/selfdrive/car/gm/interface.py b/selfdrive/car/gm/interface.py index 0287ca8cb03c78..b7d4b9f095743d 100755 --- a/selfdrive/car/gm/interface.py +++ b/selfdrive/car/gm/interface.py @@ -39,6 +39,10 @@ def __init__(self, CP, sendcan=None): self.can_invalid_count = 0 self.acc_active_prev = 0 + # First engagement must be done with "set/-", + # ignore "res/+" until then. + self.allow_resume = False + # *** init the major players *** canbus = CanBus() self.CS = CarState(CP, canbus) @@ -197,6 +201,7 @@ def update(self, c): # cruise state ret.cruiseState.available = bool(self.CS.main_on) + self.allow_resume &= ret.cruiseState.available cruiseEnabled = self.CS.pcm_acc_status in [AccState.ACTIVE, AccState.STANDSTILL] ret.cruiseState.enabled = cruiseEnabled ret.cruiseState.standstill = False @@ -232,10 +237,12 @@ def update(self, c): be.pressed = False but = self.CS.prev_cruise_buttons if but == CruiseButtons.RES_ACCEL: - if not (cruiseEnabled and self.CS.standstill): - be.type = 'accelCruise' # Suppress resume button if we're resuming from stop so we don't adjust speed. + # Suppress resume button if we're resuming from stop so we don't adjust speed. + if self.allow_resume and not (cruiseEnabled and self.CS.standstill): + be.type = 'accelCruise' elif but == CruiseButtons.DECEL_SET: be.type = 'decelCruise' + self.allow_resume = True elif but == CruiseButtons.CANCEL: be.type = 'cancel' elif but == CruiseButtons.MAIN: