@ -13,6 +13,8 @@ LongCtrlState = car.CarControl.Actuators.LongControlState
# Camera cancels up to 0.1s after brake is pressed, ECM allows 0.5s
# Camera cancels up to 0.1s after brake is pressed, ECM allows 0.5s
CAMERA_CANCEL_DELAY_FRAMES = 10
CAMERA_CANCEL_DELAY_FRAMES = 10
# Enforce a minimum interval between steering messages to avoid a fault
MIN_STEER_MSG_INTERVAL_MS = 15
class CarController :
class CarController :
@ -37,7 +39,7 @@ class CarController:
self . packer_obj = CANPacker ( DBC [ self . CP . carFingerprint ] [ ' radar ' ] )
self . packer_obj = CANPacker ( DBC [ self . CP . carFingerprint ] [ ' radar ' ] )
self . packer_ch = CANPacker ( DBC [ self . CP . carFingerprint ] [ ' chassis ' ] )
self . packer_ch = CANPacker ( DBC [ self . CP . carFingerprint ] [ ' chassis ' ] )
def update ( self , CC , CS ) :
def update ( self , CC , CS , now_nanos ) :
actuators = CC . actuators
actuators = CC . actuators
hud_control = CC . hudControl
hud_control = CC . hudControl
hud_alert = hud_control . visualAlert
hud_alert = hud_control . visualAlert
@ -64,9 +66,10 @@ class CarController:
self . lka_steering_cmd_counter + = 1
self . lka_steering_cmd_counter + = 1
self . sent_lka_steering_cmd = True
self . sent_lka_steering_cmd = True
# Avoid GM EPS faults when transmitting messages too close together: skip this transmit if we just
# Avoid GM EPS faults when transmitting messages too close together: skip this transmit if we
# received the ASCMLKASteeringCmd loopback confirmation in the current CS frame
# received the ASCMLKASteeringCmd loopback confirmation too recently
if ( self . frame - self . last_steer_frame ) > = steer_step and not CS . loopback_lka_steering_cmd_updated :
last_lka_steer_msg_ms = ( now_nanos - CS . loopback_lka_steering_cmd_ts_nanos ) * 1e-6
if ( self . frame - self . last_steer_frame ) > = steer_step and last_lka_steer_msg_ms > MIN_STEER_MSG_INTERVAL_MS :
# Initialize ASCMLKASteeringCmd counter using the camera until we get a msg on the bus
# Initialize ASCMLKASteeringCmd counter using the camera until we get a msg on the bus
if not self . sent_lka_steering_cmd :
if not self . sent_lka_steering_cmd :
self . lka_steering_cmd_counter = CS . pt_lka_steering_cmd_counter + 1
self . lka_steering_cmd_counter = CS . pt_lka_steering_cmd_counter + 1