  from selfdrive.config import Conversions as CV
  from selfdrive.car.interfaces import CarStateBase
  from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD
  
  def get_can_parser(CP):
  
    signals = [
      # sig_name, sig_address, default
      ("PRNDL", "GEAR", 0),
      ("DOOR_OPEN_FL", "DOORS", 0),
      ("DOOR_OPEN_FR", "DOORS", 0),
      ("DOOR_OPEN_RL", "DOORS", 0),
      ("DOOR_OPEN_RR", "DOORS", 0),
      ("BRAKE_PRESSED_2", "BRAKE_2", 0),
      ("ACCEL_134", "ACCEL_GAS_134", 0),
      ("SPEED_LEFT", "SPEED_1", 0),
      ("SPEED_RIGHT", "SPEED_1", 0),
      ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
      ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0),
      ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0),
      ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0),
      ("STEER_ANGLE", "STEERING", 0),
      ("STEERING_RATE", "STEERING", 0),
      ("TURN_SIGNALS", "STEERING_LEVERS", 0),
      ("ACC_STATUS_2", "ACC_2", 0),
      ("HIGH_BEAM_FLASH", "STEERING_LEVERS", 0),
      ("ACC_SPEED_CONFIG_KPH", "DASHBOARD", 0),
      ("TORQUE_DRIVER", "EPS_STATUS", 0),
      ("TORQUE_MOTOR", "EPS_STATUS", 0),
      ("LKAS_STATE", "EPS_STATUS", 1),
      ("COUNTER", "EPS_STATUS", -1),
      ("TRACTION_OFF", "TRACTION_BUTTON", 0),
      ("SEATBELT_DRIVER_UNLATCHED", "SEATBELT_STATUS", 0),
    ]
  
    # It's considered invalid if it is not received for 10x the expected period (1/f).
    checks = [
      # sig_address, frequency
      ("BRAKE_2", 50),
      ("EPS_STATUS", 100),
      ("SPEED_1", 100),
      ("WHEEL_SPEEDS", 50),
      ("STEERING", 100),
      ("ACC_2", 50),
    ]
  
    return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)
  
  def get_camera_parser(CP):
    signals = [
      # sig_name, sig_address, default
      # TODO read in all the other values
      ("COUNTER", "LKAS_COMMAND", -1),
      ("CAR_MODEL", "LKAS_HUD", -1),
      ("LKAS_STATUS_OK", "LKAS_HEARTBIT", -1)
    ]
    checks = []
  
    return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)
  
  
  class CarState(CarStateBase):
    def __init__(self, CP):
      super().__init__(CP)
      can_define = CANDefine(DBC[CP.carFingerprint]['pt'])
 
</s> remove def get_can_parser(CP):

  signals = [
    # sig_name, sig_address, default
    ("STEER_ANGLE", "STEER_ANGLE_SENSOR", 0),
    ("GEAR", "GEAR_PACKET", 0),
    ("BRAKE_PRESSED", "BRAKE_MODULE", 0),
    ("GAS_PEDAL", "GAS_PEDAL", 0),
    ("WHEEL_SPEED_FL", "WHEEL_SPEEDS", 0),
    ("WHEEL_SPEED_FR", "WHEEL_SPEEDS", 0),
    ("WHEEL_SPEED_RL", "WHEEL_SPEEDS", 0),
    ("WHEEL_SPEED_RR", "WHEEL_SPEEDS", 0),
    ("DOOR_OPEN_FL", "SEATS_DOORS", 1),
    ("DOOR_OPEN_FR", "SEATS_DOORS", 1),
    ("DOOR_OPEN_RL", "SEATS_DOORS", 1),
    ("DOOR_OPEN_RR", "SEATS_DOORS", 1),
    ("SEATBELT_DRIVER_UNLATCHED", "SEATS_DOORS", 1),
    ("TC_DISABLED", "ESP_CONTROL", 1),
    ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0),
    ("STEER_RATE", "STEER_ANGLE_SENSOR", 0),
    ("CRUISE_ACTIVE", "PCM_CRUISE", 0),
    ("CRUISE_STATE", "PCM_CRUISE", 0),
    ("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR", 0),
    ("STEER_TORQUE_EPS", "STEER_TORQUE_SENSOR", 0),
    ("TURN_SIGNALS", "STEERING_LEVERS", 3),   # 3 is no blinkers
    ("LKA_STATE", "EPS_STATUS", 0),
    ("IPAS_STATE", "EPS_STATUS", 1),
    ("BRAKE_LIGHTS_ACC", "ESP_CONTROL", 0),
    ("AUTO_HIGH_BEAM", "LIGHT_STALK", 0),
  ]

  checks = [
    ("BRAKE_MODULE", 40),
    ("GAS_PEDAL", 33),
    ("WHEEL_SPEEDS", 80),
    ("STEER_ANGLE_SENSOR", 80),
    ("PCM_CRUISE", 33),
    ("STEER_TORQUE_SENSOR", 50),
    ("EPS_STATUS", 25),
  ]

  if CP.carFingerprint == CAR.LEXUS_IS:
    signals.append(("MAIN_ON", "DSU_CRUISE", 0))
    signals.append(("SET_SPEED", "DSU_CRUISE", 0))
    checks.append(("DSU_CRUISE", 5))
  else:
    signals.append(("MAIN_ON", "PCM_CRUISE_2", 0))
    signals.append(("SET_SPEED", "PCM_CRUISE_2", 0))
    signals.append(("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 0))
    checks.append(("PCM_CRUISE_2", 33))

  if CP.carFingerprint in NO_DSU_CAR:
    signals += [("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0)]

  if CP.carFingerprint == CAR.PRIUS:
    signals += [("STATE", "AUTOPARK_STATUS", 0)]

  # add gas interceptor reading if we are using it
  if CP.enableGasInterceptor:
    signals.append(("INTERCEPTOR_GAS", "GAS_SENSOR", 0))
    signals.append(("INTERCEPTOR_GAS2", "GAS_SENSOR", 0))
    checks.append(("GAS_SENSOR", 50))

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)


def get_cam_can_parser(CP):

  signals = [("FORCE", "PRE_COLLISION", 0), ("PRECOLLISION_ACTIVE", "PRE_COLLISION", 0)]

  # use steering message to check if panda is connected to frc
  checks = [("STEERING_LKA", 42)]

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)


 </s> add  </s> remove def get_can_parser(CP):

  signals = [
    # sig_name, sig_address, default
    ("WHL_SPD_FL", "WHL_SPD11", 0),
    ("WHL_SPD_FR", "WHL_SPD11", 0),
    ("WHL_SPD_RL", "WHL_SPD11", 0),
    ("WHL_SPD_RR", "WHL_SPD11", 0),

    ("YAW_RATE", "ESP12", 0),

    ("CF_Gway_DrvSeatBeltInd", "CGW4", 1),

    ("CF_Gway_DrvSeatBeltSw", "CGW1", 0),
    ("CF_Gway_TSigLHSw", "CGW1", 0),
    ("CF_Gway_TurnSigLh", "CGW1", 0),
    ("CF_Gway_TSigRHSw", "CGW1", 0),
    ("CF_Gway_TurnSigRh", "CGW1", 0),
    ("CF_Gway_ParkBrakeSw", "CGW1", 0),

    ("BRAKE_ACT", "EMS12", 0),
    ("PV_AV_CAN", "EMS12", 0),
    ("TPS", "EMS12", 0),

    ("CYL_PRES", "ESP12", 0),

    ("CF_Clu_CruiseSwState", "CLU11", 0),
    ("CF_Clu_CruiseSwMain", "CLU11", 0),
    ("CF_Clu_SldMainSW", "CLU11", 0),
    ("CF_Clu_ParityBit1", "CLU11", 0),
    ("CF_Clu_VanzDecimal" , "CLU11", 0),
    ("CF_Clu_Vanz", "CLU11", 0),
    ("CF_Clu_SPEED_UNIT", "CLU11", 0),
    ("CF_Clu_DetentOut", "CLU11", 0),
    ("CF_Clu_RheostatLevel", "CLU11", 0),
    ("CF_Clu_CluInfo", "CLU11", 0),
    ("CF_Clu_AmpInfo", "CLU11", 0),
    ("CF_Clu_AliveCnt1", "CLU11", 0),

    ("CF_Clu_InhibitD", "CLU15", 0),
    ("CF_Clu_InhibitP", "CLU15", 0),
    ("CF_Clu_InhibitN", "CLU15", 0),
    ("CF_Clu_InhibitR", "CLU15", 0),

    ("CF_Lvr_Gear", "LVR12",0),
    ("CUR_GR", "TCU12",0),

    ("ACCEnable", "TCS13", 0),
    ("ACC_REQ", "TCS13", 0),
    ("DriverBraking", "TCS13", 0),
    ("DriverOverride", "TCS13", 0),

    ("ESC_Off_Step", "TCS15", 0),

    ("CF_Lvr_GearInf", "LVR11", 0),        #Transmission Gear (0 = N or P, 1-8 = Fwd, 14 = Rev)

    ("CR_Mdps_DrvTq", "MDPS11", 0),

    ("CR_Mdps_StrColTq", "MDPS12", 0),
    ("CF_Mdps_ToiActive", "MDPS12", 0),
    ("CF_Mdps_ToiUnavail", "MDPS12", 0),
    ("CF_Mdps_FailStat", "MDPS12", 0),
    ("CR_Mdps_OutTq", "MDPS12", 0),

    ("VSetDis", "SCC11", 0),
    ("SCCInfoDisplay", "SCC11", 0),
    ("ACCMode", "SCC12", 1),

    ("SAS_Angle", "SAS11", 0),
    ("SAS_Speed", "SAS11", 0),
  ]

  checks = [
    # address, frequency
    ("MDPS12", 50),
    ("MDPS11", 100),
    ("TCS15", 10),
    ("TCS13", 50),
    ("CLU11", 50),
    ("ESP12", 100),
    ("EMS12", 100),
    ("CGW1", 10),
    ("CGW4", 5),
    ("WHL_SPD11", 50),
    ("SCC11", 50),
    ("SCC12", 50),
    ("SAS11", 100)
  ]

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)


def get_camera_parser(CP):

  signals = [
    # sig_name, sig_address, default
    ("CF_Lkas_LdwsSysState", "LKAS11", 0),
    ("CF_Lkas_SysWarning", "LKAS11", 0),
    ("CF_Lkas_LdwsLHWarning", "LKAS11", 0),
    ("CF_Lkas_LdwsRHWarning", "LKAS11", 0),
    ("CF_Lkas_HbaLamp", "LKAS11", 0),
    ("CF_Lkas_FcwBasReq", "LKAS11", 0),
    ("CF_Lkas_ToiFlt", "LKAS11", 0),
    ("CF_Lkas_HbaSysState", "LKAS11", 0),
    ("CF_Lkas_FcwOpt", "LKAS11", 0),
    ("CF_Lkas_HbaOpt", "LKAS11", 0),
    ("CF_Lkas_FcwSysState", "LKAS11", 0),
    ("CF_Lkas_FcwCollisionWarning", "LKAS11", 0),
    ("CF_Lkas_FusionState", "LKAS11", 0),
    ("CF_Lkas_FcwOpt_USM", "LKAS11", 0),
    ("CF_Lkas_LdwsOpt_USM", "LKAS11", 0)
  ]

  checks = []

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)


 </s> add  </s> remove def get_powertrain_can_parser(CP):
  # this function generates lists for signal, messages and initial values
  signals = [
    # sig_name, sig_address, default
    ("BrakePedalPosition", "EBCMBrakePedalPosition", 0),
    ("FrontLeftDoor", "BCMDoorBeltStatus", 0),
    ("FrontRightDoor", "BCMDoorBeltStatus", 0),
    ("RearLeftDoor", "BCMDoorBeltStatus", 0),
    ("RearRightDoor", "BCMDoorBeltStatus", 0),
    ("LeftSeatBelt", "BCMDoorBeltStatus", 0),
    ("RightSeatBelt", "BCMDoorBeltStatus", 0),
    ("TurnSignals", "BCMTurnSignals", 0),
    ("AcceleratorPedal", "AcceleratorPedal", 0),
    ("ACCButtons", "ASCMSteeringButton", CruiseButtons.UNPRESS),
    ("SteeringWheelAngle", "PSCMSteeringAngle", 0),
    ("FLWheelSpd", "EBCMWheelSpdFront", 0),
    ("FRWheelSpd", "EBCMWheelSpdFront", 0),
    ("RLWheelSpd", "EBCMWheelSpdRear", 0),
    ("RRWheelSpd", "EBCMWheelSpdRear", 0),
    ("PRNDL", "ECMPRDNL", 0),
    ("LKADriverAppldTrq", "PSCMStatus", 0),
    ("LKATorqueDeliveredStatus", "PSCMStatus", 0),
  ]

  if CP.carFingerprint == CAR.VOLT:
    signals += [
      ("RegenPaddle", "EBCMRegenPaddle", 0),
    ]
  if CP.carFingerprint in SUPERCRUISE_CARS:
    signals += [
      ("ACCCmdActive", "ASCMActiveCruiseControlStatus", 0)
    ]
  else:
    signals += [
      ("TractionControlOn", "ESPStatus", 0),
      ("EPBClosed", "EPBStatus", 0),
      ("CruiseMainOn", "ECMEngineStatus", 0),
      ("CruiseState", "AcceleratorPedal2", 0),
    ]

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, [], CanBus.POWERTRAIN)
 </s> add  </s> remove def get_mqb_pt_can_parser(CP):
  # this function generates lists for signal, messages and initial values
  signals = [
    # sig_name, sig_address, default
    ("LWI_Lenkradwinkel", "LWI_01", 0),           # Absolute steering angle
    ("LWI_VZ_Lenkradwinkel", "LWI_01", 0),        # Steering angle sign
    ("LWI_Lenkradw_Geschw", "LWI_01", 0),         # Absolute steering rate
    ("LWI_VZ_Lenkradw_Geschw", "LWI_01", 0),      # Steering rate sign
    ("ESP_VL_Radgeschw_02", "ESP_19", 0),         # ABS wheel speed, front left
    ("ESP_VR_Radgeschw_02", "ESP_19", 0),         # ABS wheel speed, front right
    ("ESP_HL_Radgeschw_02", "ESP_19", 0),         # ABS wheel speed, rear left
    ("ESP_HR_Radgeschw_02", "ESP_19", 0),         # ABS wheel speed, rear right
    ("ESP_Gierrate", "ESP_02", 0),                # Absolute yaw rate
    ("ESP_VZ_Gierrate", "ESP_02", 0),             # Yaw rate sign
    ("ZV_FT_offen", "Gateway_72", 0),             # Door open, driver
    ("ZV_BT_offen", "Gateway_72", 0),             # Door open, passenger
    ("ZV_HFS_offen", "Gateway_72", 0),            # Door open, rear left
    ("ZV_HBFS_offen", "Gateway_72", 0),           # Door open, rear right
    ("ZV_HD_offen", "Gateway_72", 0),             # Trunk or hatch open
    ("BH_Blinker_li", "Gateway_72", 0),           # Left turn signal on
    ("BH_Blinker_re", "Gateway_72", 0),           # Right turn signal on
    ("GE_Fahrstufe", "Getriebe_11", 0),           # Auto trans gear selector position
    ("AB_Gurtschloss_FA", "Airbag_02", 0),        # Seatbelt status, driver
    ("AB_Gurtschloss_BF", "Airbag_02", 0),        # Seatbelt status, passenger
    ("ESP_Fahrer_bremst", "ESP_05", 0),           # Brake pedal pressed
    ("ESP_Status_Bremsdruck", "ESP_05", 0),       # Brakes applied
    ("ESP_Bremsdruck", "ESP_05", 0),              # Brake pressure applied
    ("MO_Fahrpedalrohwert_01", "Motor_20", 0),    # Accelerator pedal value
    ("MO_Kuppl_schalter", "Motor_14", 0),         # Clutch switch
    ("Driver_Strain", "EPS_01", 0),               # Absolute driver torque input
    ("Driver_Strain_VZ", "EPS_01", 0),            # Driver torque input sign
    ("HCA_Ready", "EPS_01", 0),                   # Steering rack HCA support configured
    ("ESP_Tastung_passiv", "ESP_21", 0),          # Stability control disabled
    ("KBI_MFA_v_Einheit_02", "Einheiten_01", 0),  # MPH vs KMH speed display
    ("KBI_Handbremse", "Kombi_01", 0),            # Manual handbrake applied
    ("TSK_Fahrzeugmasse_02", "Motor_16", 0),      # Estimated vehicle mass from drivetrain coordinator
    ("ACC_Status_ACC", "ACC_06", 0),              # ACC engagement status
    ("ACC_Typ", "ACC_06", 0),                     # ACC type (follow to stop, stop&go)
    ("SetSpeed", "ACC_02", 0),                    # ACC set speed
    ("GRA_Hauptschalter", "GRA_ACC_01", 0),       # ACC button, on/off
    ("GRA_Abbrechen", "GRA_ACC_01", 0),           # ACC button, cancel
    ("GRA_Tip_Setzen", "GRA_ACC_01", 0),          # ACC button, set
    ("GRA_Tip_Hoch", "GRA_ACC_01", 0),            # ACC button, increase or accel
    ("GRA_Tip_Runter", "GRA_ACC_01", 0),          # ACC button, decrease or decel
    ("GRA_Tip_Wiederaufnahme", "GRA_ACC_01", 0),  # ACC button, resume
    ("GRA_Verstellung_Zeitluecke", "GRA_ACC_01", 0), # ACC button, time gap adj
    ("GRA_Typ_Hauptschalter", "GRA_ACC_01", 0),   # ACC main button type
    ("GRA_Tip_Stufe_2", "GRA_ACC_01", 0),         # unknown related to stalk type
    ("GRA_ButtonTypeInfo", "GRA_ACC_01", 0),      # unknown related to stalk type
    ("COUNTER", "GRA_ACC_01", 0),                 # GRA_ACC_01 CAN message counter
  ]

  checks = [
    # sig_address, frequency
    ("LWI_01", 100),      # From J500 Steering Assist with integrated sensors
    ("EPS_01", 100),      # From J500 Steering Assist with integrated sensors
    ("ESP_19", 100),      # From J104 ABS/ESP controller
    ("ESP_05", 50),       # From J104 ABS/ESP controller
    ("ESP_21", 50),       # From J104 ABS/ESP controller
    ("ACC_06", 50),       # From J428 ACC radar control module
    ("Motor_20", 50),     # From J623 Engine control module
    ("GRA_ACC_01", 33),   # From J??? steering wheel control buttons
    ("ACC_02", 17),       # From J428 ACC radar control module
    ("Getriebe_11", 20),  # From J743 Auto transmission control module
    ("Gateway_72", 10),   # From J533 CAN gateway (aggregated data)
    ("Motor_14", 10),     # From J623 Engine control module
    ("Airbag_02", 5),     # From J234 Airbag control module
    ("Kombi_01", 2),      # From J285 Instrument cluster
    ("Motor_16", 2),      # From J623 Engine control module
    ("Einheiten_01", 1),  # From J??? not known if gateway, cluster, or BCM
  ]

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, CANBUS.pt)

# A single signal is monitored from the camera CAN bus, and then ignored,
# so the presence of CAN traffic can be verified with cam_cp.valid.

def get_mqb_cam_can_parser(CP):

  signals = [
    # sig_name, sig_address, default
    ("Kombi_Lamp_Green", "LDW_02", 0),            # Lane Assist status LED
  ]

  checks = [
    # sig_address, frequency
    ("LDW_02", 10)        # From R242 Driver assistance camera
  ]

  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, CANBUS.cam)


 </s> add  </s> remove def get_can_parser(CP):
  signals, checks = get_can_signals(CP)
  bus_pt = 1 if CP.isPandaBlack and CP.carFingerprint in HONDA_BOSCH else 0
  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_pt)


def get_cam_can_parser(CP):
  signals = []

  if CP.carFingerprint in HONDA_BOSCH:
    signals += [("ACCEL_COMMAND", "ACC_CONTROL", 0),
                ("AEB_STATUS", "ACC_CONTROL", 0)]
  else:
    signals += [("COMPUTER_BRAKE", "BRAKE_COMMAND", 0),
                ("AEB_REQ_1", "BRAKE_COMMAND", 0),
                ("FCW", "BRAKE_COMMAND", 0),
                ("CHIME", "BRAKE_COMMAND", 0),
                ("FCM_OFF", "ACC_HUD", 0),
                ("FCM_OFF_2", "ACC_HUD", 0),
                ("FCM_PROBLEM", "ACC_HUD", 0),
                ("ICONS", "ACC_HUD", 0)]


  # all hondas except CRV, RDX and 2019 Odyssey@China use 0xe4 for steering
  checks = [(0xe4, 100)]
  if CP.carFingerprint in [CAR.CRV, CAR.ACURA_RDX, CAR.ODYSSEY_CHN]:
    checks = [(0x194, 100)]

  bus_cam = 1 if CP.carFingerprint in HONDA_BOSCH  and not CP.isPandaBlack else 2
  return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, bus_cam)

 </s> add 
  from selfdrive.config import Conversions as CV
  from selfdrive.car.interfaces import CarStateBase
  from selfdrive.car.chrysler.values import DBC, STEER_THRESHOLD
  
























































  
  class CarState(CarStateBase):
    def __init__(self, CP):
      super().__init__(CP)
      can_define = CANDefine(DBC[CP.carFingerprint]['pt'])
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
 get_can_parser and get_cam_can_parser are now standard static methods (#1136) 
selfdrive/car/chrysler/carstate.py