all changes

This commit is contained in:
Shane Smiskol
2026-06-05 18:51:20 -07:00
parent f15cc7673a
commit 0935836bcc
5 changed files with 41 additions and 0 deletions

View File

@@ -201,6 +201,8 @@ struct CarState {
espDisabled @32 :Bool;
accFaulted @42 :Bool;
carFaultedNonCritical @47 :Bool; # some ECU is faulted, but car remains controllable
radarDirty @61 :Bool; # car/DSU reports the radar sensor is dirty/obstructed (HUD "clean radar sensor")
accMalfunction @62 :Bool; # car/DSU reports ACC malfunction
espActive @51 :Bool;
vehicleSensorsInvalid @52 :Bool; # invalid steering angle readings, etc.
lowSpeedAlert @56 :Bool; # lost steering control due to a dynamic min steering speed

View File

@@ -150,6 +150,11 @@ class CarState(CarStateBase):
self.acc_type = cp_acc.vl["ACC_CONTROL"]["ACC_TYPE"]
ret.stockFcw = bool(cp_acc.vl["PCS_HUD"]["FCW"])
# ACC_CONTROL status flags — present on cars where the DSU/camera sends ACC_CONTROL to the car.
if self.CP.carFingerprint not in UNSUPPORTED_DSU_CAR and self.CP.carFingerprint not in (RADAR_ACC_CAR | SECOC_CAR):
ret.radarDirty = cp_acc.vl["ACC_CONTROL"]["RADAR_DIRTY"] != 0
ret.accMalfunction = cp_acc.vl["ACC_CONTROL"]["ACC_MALFUNCTION"] != 0
# some TSS2 cars have low speed lockout permanently set, so ignore on those cars
# these cars are identified by an ACC_TYPE value of 2.
# TODO: it is possible to avoid the lockout and gain stop and go if you

View File

@@ -5,6 +5,8 @@ from opendbc.car.structs import RadarData
from opendbc.car.toyota.values import DBC, TSS2_CAR
from opendbc.car.interfaces import RadarInterfaceBase
RADAR_TRACKS_ACTIVE_ADDR = 0x123
def _create_radar_can_parser(car_fingerprint):
if car_fingerprint in TSS2_CAR:
@@ -17,6 +19,10 @@ def _create_radar_can_parser(car_fingerprint):
msg_a_n = len(RADAR_A_MSGS)
msg_b_n = len(RADAR_B_MSGS)
messages = list(zip(RADAR_A_MSGS + RADAR_B_MSGS, [20] * (msg_a_n + msg_b_n), strict=True))
# 0x123 broadcasts a "tracks active" flag the radar firmware clears when it suppresses
# all targets (observed on TSS-P at standstill). 10Hz nominal but not enforced —
# cars without 0x123 (e.g. TSS2) shouldn't trip canError.
messages.append((RADAR_TRACKS_ACTIVE_ADDR, 10))
return CANParser(DBC[car_fingerprint][Bus.radar], messages, 1)
@@ -34,6 +40,10 @@ class RadarInterface(RadarInterfaceBase):
self.RADAR_B_MSGS = list(range(0x220, 0x230))
self.valid_cnt = {key: 0 for key in self.RADAR_A_MSGS}
# None until we've ever seen 0x123 on this car. Two redundant bits in the same msg
# — expected to mirror each other; logging both as a sanity check.
self.tracks_active_b2 = None
self.tracks_active_b6 = None
self.rcp = None if CP.radarUnavailable else _create_radar_can_parser(CP.carFingerprint)
self.trigger_msg = self.RADAR_B_MSGS[-1]
@@ -59,6 +69,16 @@ class RadarInterface(RadarInterfaceBase):
if not self.rcp.can_valid:
ret.errors.canError = True
# Latch the 0x123 tracks-active flags whenever the message arrives. If we've ever seen
# them and either is currently clear, the radar firmware is suppressing all targets.
if RADAR_TRACKS_ACTIVE_ADDR in updated_messages:
self.tracks_active_b2 = bool(self.rcp.vl[RADAR_TRACKS_ACTIVE_ADDR]['TRACKS_ACTIVE_B2'])
self.tracks_active_b6 = bool(self.rcp.vl[RADAR_TRACKS_ACTIVE_ADDR]['TRACKS_ACTIVE_B6'])
if self.tracks_active_b2 is False or self.tracks_active_b6 is False:
ret.errors.radarUnavailableTemporary = True
print(ret.errors)
for ii in sorted(updated_messages):
if ii in self.RADAR_A_MSGS:
cpt = self.rcp.vl[ii]

View File

@@ -274,3 +274,10 @@ BO_ 559 TRACK_B_15: 6 XXX
SG_ REL_ACCEL : 15|7@0- (1,0) [-64|63] "" XXX
SG_ SCORE : 23|8@0+ (1,0) [0|100] "" XXX
SG_ CHECKSUM : 47|8@0+ (1,0) [0|255] "" XXX
BO_ 291 RADAR_TRACKS_ACTIVE: 7 XXX
SG_ TRACKS_ACTIVE_B6 : 51|1@0+ (1,0) [0|1] "" XXX
SG_ TRACKS_ACTIVE_B2 : 19|1@0+ (1,0) [0|1] "" XXX
CM_ SG_ 291 TRACKS_ACTIVE_B2 "TSS-P radar: bit goes 0 when radar suppresses all tracks (standstill / firmware lockout). Mirrors TRACKS_ACTIVE_B6.";
CM_ SG_ 291 TRACKS_ACTIVE_B6 "TSS-P radar: bit goes 0 when radar suppresses all tracks (standstill / firmware lockout). Mirrors TRACKS_ACTIVE_B2.";

View File

@@ -283,3 +283,10 @@ BO_ 576 NEW_MSG_1: 8 XXX
BO_ 577 NEW_MSG_2: 8 XXX
SG_ NEW_SIGNAL_1 : 15|7@0+ (1,0) [0|127] "" XXX
SG_ NEW_SIGNAL_2 : 23|8@0+ (1,0) [0|255] "" XXX
BO_ 291 RADAR_TRACKS_ACTIVE: 7 XXX
SG_ TRACKS_ACTIVE_B6 : 51|1@0+ (1,0) [0|1] "" XXX
SG_ TRACKS_ACTIVE_B2 : 19|1@0+ (1,0) [0|1] "" XXX
CM_ SG_ 291 TRACKS_ACTIVE_B2 "TSS-P-style suppression flag (TSS2 occurrence unverified — kept for parser symmetry). 0 when radar reports no targets.";
CM_ SG_ 291 TRACKS_ACTIVE_B6 "TSS-P-style suppression flag (TSS2 occurrence unverified — kept for parser symmetry). 0 when radar reports no targets.";