From 9c1bdde65b93bbc37449fa8944fca5e563c1627a Mon Sep 17 00:00:00 2001 From: rav4kumar Date: Tue, 3 Nov 2026 10:19:47 -0700 Subject: [PATCH] toyota: enable the enhanced BSM toggle for TSS-P cars with a smartDSU --- opendbc_repo | 2 +- .../layouts/settings/vehicle/brands/toyota.py | 11 ++++++++--- openpilot/sunnypilot/sunnylink/capabilities.py | 11 ++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/opendbc_repo b/opendbc_repo index 8a69342d74..a0f52f61af 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 8a69342d74015b0c571be38790734dce991cdd85 +Subproject commit a0f52f61afe1314295513bb394e15da8e5d1775e diff --git a/openpilot/selfdrive/ui/sunnypilot/layouts/settings/vehicle/brands/toyota.py b/openpilot/selfdrive/ui/sunnypilot/layouts/settings/vehicle/brands/toyota.py index 52d2cf1e24..aeb35ad4dd 100644 --- a/openpilot/selfdrive/ui/sunnypilot/layouts/settings/vehicle/brands/toyota.py +++ b/openpilot/selfdrive/ui/sunnypilot/layouts/settings/vehicle/brands/toyota.py @@ -17,7 +17,8 @@ from opendbc.sunnypilot.car.toyota.values import ToyotaFlagsSP ONROAD_ONLY_DESCRIPTION = tr_noop("Start the vehicle to check vehicle compatibility.") SNG_HACK_UNAVAILABLE = tr_noop("sunnypilot Longitudinal Control must be available and enabled for your vehicle to use this feature.") -BSM_UNAVAILABLE = tr_noop("Enhanced Blind Spot Monitoring requires a TSS2 Toyota/Lexus without SecOC.") +BSM_UNAVAILABLE = tr_noop("Enhanced Blind Spot Monitoring requires a TSS2 Toyota/Lexus without SecOC, " + + "or a smartDSU with sunnypilot longitudinal control.") BSM_STOCK_LONG_UNAVAILABLE = tr_noop("Enhanced Blind Spot Monitoring is not available while Enforce Factory Longitudinal Control is enabled.") BSM_REQUIRED = tr_noop("This vehicle does not report blind spot status over the standard CAN signals. " + "Enhanced Blind Spot Monitoring is required for blind spot detection.") @@ -153,8 +154,12 @@ class ToyotaSettings(BrandSettings): self.stop_and_go_hack.show_description(True) # Enhanced BSM needs the radar diagnostic address, which is only in the TX allowlist for - # TSS2 cars without SecOC that are not enforcing factory longitudinal control - bsm_supported = bool(ui_state.CP.flags & ToyotaFlags.TSS2) and not bool(ui_state.CP.flags & ToyotaFlags.SECOC) + # TSS2 cars without SecOC, or for TSS-P cars whose smartDSU lets sunnypilot control + # longitudinal. Enforcing factory longitudinal control rules both of those out. + sdsu_bsm_supported = (longitudinal and ui_state.CP_SP is not None and + bool(ui_state.CP_SP.flags & ToyotaFlagsSP.SMART_DSU)) + bsm_supported = (not bool(ui_state.CP.flags & ToyotaFlags.SECOC) and + (bool(ui_state.CP.flags & ToyotaFlags.TSS2) or sdsu_bsm_supported)) bsm_available = bsm_supported and not enforce_stock self.enhanced_bsm.action_item.set_enabled(bsm_available and not ui_state.engaged) diff --git a/openpilot/sunnypilot/sunnylink/capabilities.py b/openpilot/sunnypilot/sunnylink/capabilities.py index ed9ed8ca36..02608dd2b6 100644 --- a/openpilot/sunnypilot/sunnylink/capabilities.py +++ b/openpilot/sunnypilot/sunnylink/capabilities.py @@ -13,6 +13,7 @@ from opendbc.car.subaru.values import CAR as SUBARU_CAR, SubaruFlags from opendbc.car.toyota.values import CAR as TOYOTA_CAR, ToyotaFlags from opendbc.sunnypilot.car.interfaces import has_bsm from opendbc.sunnypilot.car.tesla.values import TeslaFlagsSP +from opendbc.sunnypilot.car.toyota.values import ToyotaFlagsSP from openpilot.common.params import Params from openpilot.common.swaglog import cloudlog from openpilot.common.hardware import HARDWARE @@ -83,7 +84,7 @@ def _bundle_field(bundle: dict | None, key: str) -> str: return bundle.get(key, "") if isinstance(bundle, dict) else "" -def _resolve_brand_capabilities(caps: dict, bundle_platform: str, CP) -> None: +def _resolve_brand_capabilities(caps: dict, bundle_platform: str, CP, CP_SP=None) -> None: """Set brand-specific capabilities from bundle platform or CarParams fallback. Bundle (manual car selection) is a pre-fingerprint approximation. @@ -122,7 +123,11 @@ def _resolve_brand_capabilities(caps: dict, bundle_platform: str, CP) -> None: except KeyError: cloudlog.exception(f"capabilities: unknown toyota platform {bundle_platform!r}") elif CP is not None: - caps["toyota_enhanced_bsm_available"] = bool(CP.flags & ToyotaFlags.TSS2) and not bool(CP.flags & ToyotaFlags.SECOC) + # same gate as _initialize_toyota: TSS2 without SecOC, or TSS-P with a smartDSU and openpilot + # longitudinal control (the bundle path can't see 0x2FF, so it stays TSS2-only) + sdsu_bsm = CP_SP is not None and bool(CP_SP.flags & ToyotaFlagsSP.SMART_DSU) and bool(CP.openpilotLongitudinalControl) + caps["toyota_enhanced_bsm_available"] = (not bool(CP.flags & ToyotaFlags.SECOC) and + (bool(CP.flags & ToyotaFlags.TSS2) or sdsu_bsm)) def generate_capabilities(params: Params | None = None) -> dict: @@ -194,7 +199,7 @@ def generate_capabilities(params: Params | None = None) -> dict: if CP is not None: caps["has_bsm"] = has_bsm(CP, CP_SP) - _resolve_brand_capabilities(caps, bundle_platform, CP) + _resolve_brand_capabilities(caps, bundle_platform, CP, CP_SP) return caps