Toyota TSS-P: parse distance button from SDSU (#31741)

* Toyota TSS-P: parse distance button from SDSU

* it's 1000hz wtf... da99509bd910288a/2024-03-04--13-51-30

* add events for SDSU

* need to check for CAN filter

* clena up

* check

* whoops

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
old-commit-hash: c4ef17ac28
pull/32199/head
Alexandre Nobuharu Sato 1 year ago committed by GitHub
parent 1ed0a0e1cb
commit edefdce5ec
  1. 10
      selfdrive/car/toyota/carstate.py
  2. 5
      selfdrive/car/toyota/interface.py
  3. 1
      selfdrive/car/toyota/values.py

@ -167,10 +167,13 @@ class CarState(CarStateBase):
self.lkas_hud = copy.copy(cp_cam.vl["LKAS_HUD"])
# distance button is wired to the ACC module (camera or radar)
self.prev_distance_button = self.distance_button
if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR):
self.prev_distance_button = self.distance_button
self.distance_button = cp_acc.vl["ACC_CONTROL"]["DISTANCE"]
elif self.CP.flags & ToyotaFlags.SMART_DSU and not self.CP.flags & ToyotaFlags.RADAR_CAN_FILTER:
self.distance_button = cp.vl["SDSU"]["FD_BUTTON"]
return ret
@staticmethod
@ -221,6 +224,11 @@ class CarState(CarStateBase):
("PRE_COLLISION", 33),
]
if CP.flags & ToyotaFlags.SMART_DSU and not CP.flags & ToyotaFlags.RADAR_CAN_FILTER:
messages += [
("SDSU", 100),
]
return CANParser(DBC[CP.carFingerprint]["pt"], messages, 0)
@staticmethod

@ -49,6 +49,9 @@ class CarInterface(CarInterfaceBase):
if 0x2FF in fingerprint[0] or (0x2AA in fingerprint[0] and candidate in NO_DSU_CAR):
ret.flags |= ToyotaFlags.SMART_DSU.value
if 0x2AA in fingerprint[0] and candidate in NO_DSU_CAR:
ret.flags |= ToyotaFlags.RADAR_CAN_FILTER.value
# In TSS2 cars, the camera does long control
found_ecus = [fw.ecu for fw in car_fw]
ret.enableDsu = len(found_ecus) > 0 and Ecu.dsu not in found_ecus and candidate not in (NO_DSU_CAR | UNSUPPORTED_DSU_CAR) \
@ -173,7 +176,7 @@ class CarInterface(CarInterfaceBase):
def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam)
if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR):
if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) or (self.CP.flags & ToyotaFlags.SMART_DSU and not self.CP.flags & ToyotaFlags.RADAR_CAN_FILTER):
ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
# events

@ -46,6 +46,7 @@ class ToyotaFlags(IntFlag):
HYBRID = 1
SMART_DSU = 2
DISABLE_RADAR = 4
RADAR_CAN_FILTER = 1024
# Static flags
TSS2 = 8

Loading…
Cancel
Save