From e1eb30f4b5d40fe3996d76ff4a265f3923ffff6b Mon Sep 17 00:00:00 2001 From: ds-sebastian Date: Sat, 28 Nov 2026 13:23:32 -0500 Subject: [PATCH] Toyota radar-ACC cars: radarUnavailableTemporary while the ARS510's fault flag is held As in commaai/opendbc#3860. EVENT_STATE (0x196) RADAR_FAULT is held while the radar declares itself blocked (car-bus PCS_DUST), as STATUS_MSG reports on the other TSS2 radars. Across comma's public fleet logs (127 radar-on hours, about 240 cars) two or more consecutive set cycles were seen only then; the single set cycle at power-up is ignored. Co-Authored-By: Claude Opus 5.5 --- .../opendbc/car/toyota/ars510_acc_target.py | 13 +++++++++++-- .../opendbc/car/toyota/tests/test_ars510.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/opendbc_repo/opendbc/car/toyota/ars510_acc_target.py b/opendbc_repo/opendbc/car/toyota/ars510_acc_target.py index c48b639688..d6bfbc8bb3 100644 --- a/opendbc_repo/opendbc/car/toyota/ars510_acc_target.py +++ b/opendbc_repo/opendbc/car/toyota/ars510_acc_target.py @@ -17,16 +17,22 @@ TARGET_ADDRS = {0x235, 0x237, 0x239} class RadarInterface(RadarInterfaceBase): def __init__(self, CP): super().__init__(CP) - self.rcp = CANParser(RADAR_DBC, [("ACC_TARGET_1", 50), ("ACC_TARGET_2", 50), ("ACC_TARGET_3", 50)], 1) + # EVENT_STATE is not required: it carries the radar's fault flag + self.rcp = CANParser(RADAR_DBC, [("ACC_TARGET_1", 50), ("ACC_TARGET_2", 50), ("ACC_TARGET_3", 50), ("EVENT_STATE", nan)], 1) self.trigger_msg = 0x237 self.updated_messages = set() self.cycle = None self.last_record_t = None + self.fault_cycles = 0 def update(self, can_strings): self.frame += 1 packets = [(nanos, [(addr, dat, src) for addr, dat, src in frames if addr not in TARGET_ADDRS or len(dat) == 8]) for nanos, frames in can_strings] - self.updated_messages.update(self.rcp.update(packets)) + updated = self.rcp.update(packets) + self.updated_messages.update(updated) + if 0x196 in updated: + # RADAR_FAULT is held while the radar declares itself blocked, and set on one cycle at power-up + self.fault_cycles = self.fault_cycles + 1 if self.rcp.vl["EVENT_STATE"]["RADAR_FAULT"] else 0 t = can_strings[-1][0] * 1e-9 if can_strings else None cycle = self.rcp.vl["ACC_TARGET_3"]["TIMESTAMP"] clock_seen = bool(self.rcp.ts_nanos["ACC_TARGET_3"]["TIMESTAMP"]) @@ -45,6 +51,9 @@ class RadarInterface(RadarInterfaceBase): if not self.rcp.can_valid: ret.errors.canError = True return ret + if self.fault_cycles >= 2: + ret.errors.radarUnavailableTemporary = True + return ret target, position = self.rcp.vl["ACC_TARGET_1"], self.rcp.vl["ACC_TARGET_2"] if target["STATE"] == 5 and position["PRESENT"]: diff --git a/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py b/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py index d72e7ff2ea..049f1b7d14 100644 --- a/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py +++ b/opendbc_repo/opendbc/car/toyota/tests/test_ars510.py @@ -99,6 +99,18 @@ def test_rav4_startup_wait_does_not_stall_live_tracks(): assert all(not r.points and not r.errors.radarUnavailableTemporary for r in outputs if r is not None) +def test_acc_target_reports_unavailable_while_the_fault_flag_is_held(): + # EVENT_STATE RADAR_FAULT: one set cycle (power-up) is ignored, two or more report radarUnavailableTemporary + radar = AccRadarInterface(structs.CarParams()) + packer = CANPacker(RADAR_DBC) + reports = [] + for i, fault in enumerate((True, False, True, True, True, False)): + frames = [packer.make_can_msg("EVENT_STATE", 1, {"RADAR_FAULT": int(fault)})] + acc_frames(packer, i, 60000 * (i + 1)) + ret = radar.update([(1_000_000_000 + i * 60_000_000, frames)]) + reports.append((ret.errors.radarUnavailableTemporary, len(ret.points))) + assert reports == [(False, 1), (False, 1), (False, 1), (True, 0), (True, 0), (False, 1)] + + @pytest.mark.parametrize('candidate', sorted(ARS510_RADAR_CAR)) def test_pcs_alarm_sets_stock_fcw_on_ars510_cars(candidate): from opendbc.can import CANParser