diff --git a/selfdrive/car/toyota/carstate.py b/selfdrive/car/toyota/carstate.py index 3b9b85e..dd8dd6f 100644 --- a/selfdrive/car/toyota/carstate.py +++ b/selfdrive/car/toyota/carstate.py @@ -143,9 +143,9 @@ class CarState(CarStateBase): conversion_factor = CV.KPH_TO_MS if is_metric else CV.MPH_TO_MS ret.cruiseState.speedCluster = cluster_set_speed * conversion_factor - cp_acc = cp_cam if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) else cp + cp_acc = cp_cam if (self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) or bool(self.CP.flags & ToyotaFlags.DSU_BYPASS.value)) else cp - if self.CP.carFingerprint in TSS2_CAR and not self.CP.flags & ToyotaFlags.DISABLE_RADAR.value: + if (self.CP.flags & ToyotaFlags.DSU_BYPASS.value) or (self.CP.carFingerprint in TSS2_CAR and not self.CP.flags & ToyotaFlags.DISABLE_RADAR.value): if not (self.CP.flags & ToyotaFlags.SMART_DSU.value): self.acc_type = cp_acc.vl["ACC_CONTROL"]["ACC_TYPE"] ret.stockFcw = bool(cp_acc.vl["PCS_HUD"]["FCW"]) @@ -261,7 +261,7 @@ class CarState(CarStateBase): ("PCS_HUD", 1), ] - if CP.carFingerprint not in (TSS2_CAR - RADAR_ACC_CAR) and not CP.enableDsu and not CP.flags & ToyotaFlags.DISABLE_RADAR.value: + if CP.carFingerprint not in (TSS2_CAR - RADAR_ACC_CAR) and not CP.enableDsu and not (CP.flags & ToyotaFlags.DISABLE_RADAR.value or CP.flags & ToyotaFlags.DSU_BYPASS.value): messages += [ ("PRE_COLLISION", 33), ] @@ -284,7 +284,7 @@ class CarState(CarStateBase): ("LKAS_HUD", 1), ] - if CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR): + if CP.flags & ToyotaFlags.DSU_BYPASS.value or CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR): messages += [ ("PRE_COLLISION", 33), ("ACC_CONTROL", 33), diff --git a/selfdrive/car/toyota/interface.py b/selfdrive/car/toyota/interface.py index 13b6b40..b6582ce 100644 --- a/selfdrive/car/toyota/interface.py +++ b/selfdrive/car/toyota/interface.py @@ -56,6 +56,11 @@ class CarInterface(CarInterfaceBase): if 0x2AA in fingerprint[0] and candidate in NO_DSU_CAR: ret.flags |= ToyotaFlags.RADAR_CAN_FILTER.value + # 0x343 should not be present on bus 2 on cars other than TSS2_CAR unless we are re-routing DSU + if (0x343 in fingerprint[2] or 0x4CB in fingerprint[2]) and candidate not in TSS2_CAR: + if not (ret.flags & ToyotaFlags.SMART_DSU.value): + ret.flags |= ToyotaFlags.DSU_BYPASS.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) \ @@ -136,6 +141,7 @@ class CarInterface(CarInterfaceBase): # - TSS2 radar ACC cars w/o smartDSU installed (disables radar) # - TSS-P DSU-less cars w/ CAN filter installed (no radar parser yet) ret.openpilotLongitudinalControl = use_sdsu or ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) + ret.openpilotLongitudinalControl |= bool(ret.flags & ToyotaFlags.DSU_BYPASS.value) ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR ret.enableGasInterceptor = 0x201 in fingerprint[0] and ret.openpilotLongitudinalControl diff --git a/selfdrive/car/toyota/values.py b/selfdrive/car/toyota/values.py index e2a519b..6b26e0e 100644 --- a/selfdrive/car/toyota/values.py +++ b/selfdrive/car/toyota/values.py @@ -60,6 +60,7 @@ class ToyotaFlags(IntFlag): SNG_WITHOUT_DSU = 512 # FrogPilot Toyota flags + DSU_BYPASS = 1024 ZSS = 2048 class Footnote(Enum):