@ -48,11 +48,15 @@ class CarState(CarStateBase):
ret . steeringTorque = cp . vl [ " Steering_Torque " ] [ ' Steer_Torque_Sensor ' ]
ret . steeringPressed = abs ( ret . steeringTorque ) > STEER_THRESHOLD [ self . car_fingerprint ]
ret . steerError = cp . vl [ " Steering_Torque " ] [ ' Steer_Error_1 ' ] == 1
ret . steerWarning = cp . vl [ " Steering_Torque " ] [ ' Steer_Warning ' ] == 1
ret . cruiseState . enabled = cp . vl [ " CruiseControl " ] [ ' Cruise_Activated ' ] != 0
ret . cruiseState . available = cp . vl [ " CruiseControl " ] [ ' Cruise_On ' ] != 0
ret . cruiseState . speed = cp_cam . vl [ " ES_DashStatus " ] [ ' Cruise_Set_Speed ' ] * CV . KPH_TO_MS
# EDM Impreza: 1 = mph, UDM Forester: 7 = mph
if cp . vl [ " Dash_State " ] [ ' Units ' ] in [ 1 , 7 ] :
ret . cruiseState . nonAdaptive = cp_cam . vl [ " ES_DashStatus " ] [ ' Conventional_Cruise ' ] == 1
# EDM Impreza: 1,2 = mph, UDM Forester: 7 = mph
if cp . vl [ " Dash_State " ] [ ' Units ' ] in [ 1 , 2 , 7 ] :
ret . cruiseState . speed * = CV . MPH_TO_KPH
ret . seatbeltUnlatched = cp . vl [ " Dashlights " ] [ ' SEATBELT_FL ' ] == 1
@ -73,6 +77,8 @@ class CarState(CarStateBase):
# sig_name, sig_address, default
( " Steer_Torque_Sensor " , " Steering_Torque " , 0 ) ,
( " Steering_Angle " , " Steering_Torque " , 0 ) ,
( " Steer_Error_1 " , " Steering_Torque " , 0 ) ,
( " Steer_Warning " , " Steering_Torque " , 0 ) ,
( " Cruise_On " , " CruiseControl " , 0 ) ,
( " Cruise_Activated " , " CruiseControl " , 0 ) ,
( " Brake_Pedal " , " Brake_Pedal " , 0 ) ,
@ -111,12 +117,25 @@ class CarState(CarStateBase):
def get_cam_can_parser ( CP ) :
signals = [
( " Cruise_Set_Speed " , " ES_DashStatus " , 0 ) ,
( " Conventional_Cruise " , " ES_DashStatus " , 0 ) ,
( " Counter " , " ES_Distance " , 0 ) ,
( " Signal1 " , " ES_Distance " , 0 ) ,
( " Cruise_Fault " , " ES_Distance " , 0 ) ,
( " Cruise_Throttle " , " ES_Distance " , 0 ) ,
( " Signal2 " , " ES_Distance " , 0 ) ,
( " Main " , " ES_Distance " , 0 ) ,
( " Car_Follow " , " ES_Distance " , 0 ) ,
( " Signal3 " , " ES_Distance " , 0 ) ,
( " Cruise_Brake_Active " , " ES_Distance " , 0 ) ,
( " Distance_Swap " , " ES_Distance " , 0 ) ,
( " Cruise_EPB " , " ES_Distance " , 0 ) ,
( " Signal4 " , " ES_Distance " , 0 ) ,
( " Close_Distance " , " ES_Distance " , 0 ) ,
( " Signal5 " , " ES_Distance " , 0 ) ,
( " Cruise_Cancel " , " ES_Distance " , 0 ) ,
( " Cruise_Set " , " ES_Distance " , 0 ) ,
( " Cruise_Resume " , " ES_Distance " , 0 ) ,
( " Signal6 " , " ES_Distance " , 0 ) ,
( " Counter " , " ES_LKAS_State " , 0 ) ,
( " Keep_Hands_On_Wheel " , " ES_LKAS_State " , 0 ) ,
@ -126,23 +145,21 @@ class CarState(CarStateBase):
( " Signal2 " , " ES_LKAS_State " , 0 ) ,
( " Backward_Speed_Limit_Menu " , " ES_LKAS_State " , 0 ) ,
( " LKAS_ENABLE_3 " , " ES_LKAS_State " , 0 ) ,
( " Signal3 " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Left_Line_Light_Blink " , " ES_LKAS_State " , 0 ) ,
( " LKAS_ENABLE_2 " , " ES_LKAS_State " , 0 ) ,
( " Signal4 " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Right_Line_Light_Blink " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Left_Line_Visible " , " ES_LKAS_State " , 0 ) ,
( " Signal6 " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Left_Line_Green " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Right_Line_Visible " , " ES_LKAS_State " , 0 ) ,
( " Signal7 " , " ES_LKAS_State " , 0 ) ,
( " FCW_Cont_Beep " , " ES_LKAS_State " , 0 ) ,
( " FCW_Repeated_Beep " , " ES_LKAS_State " , 0 ) ,
( " Throttle_Management_Activated " , " ES_LKAS_State " , 0 ) ,
( " Traffic_light_Ahead " , " ES_LKAS_State " , 0 ) ,
( " Right_Depart " , " ES_LKAS_State " , 0 ) ,
( " Signal5 " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Right_Line_Green " , " ES_LKAS_State " , 0 ) ,
( " LKAS_Alert " , " ES_LKAS_State " , 0 ) ,
( " Signal3 " , " ES_LKAS_State " , 0 ) ,
]
checks = [
( " ES_DashStatus " , 10 ) ,
( " ES_Distance " , 20 ) ,
( " ES_LKAS_State " , 10 ) ,
]
return CANParser ( DBC [ CP . carFingerprint ] [ ' pt ' ] , signals , checks , 2 )