def get_camera_parser(CP): signals = [ # sig_name, sig_address, default ("CF_Lkas_Icon", "LKAS11", 0), ("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), ("CF_Lkas_Unknown1", "LKAS11", 0), ("CF_Lkas_Unknown2", "LKAS11", 0), ("CF_Lkas_ActToi", "LKAS11", 0), ("CR_Lkas_StrToqReq", "LKAS11", 0), ("CF_Lkas_MsgCount", "LKAS11", 0), ("CF_Lkas_Chksum", "LKAS11", 0) ] checks = [("LKAS11", 100)] return (CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)), \ (CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 1))
def run_route(route): can = messaging.pub_sock(service_list['can'].port) CP = CarInterface.get_params(CAR.CIVIC, {}) signals, checks = get_can_signals(CP) parser_old = CANParserOld(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1, tcp_addr="127.0.0.1") parser_new = CANParserNew(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1, tcp_addr="127.0.0.1") parser_string = CANParserNew(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=-1) if dict_keys_differ(parser_old.vl, parser_new.vl): return False lr = LogReader(route + ".bz2") route_ok = True t = 0 for msg in lr: if msg.which() == 'can': t += DT msg_bytes = msg.as_builder().to_bytes() can.send(msg_bytes) _, updated_old = parser_old.update(t, True) _, updated_new = parser_new.update(t, True) updated_string = parser_string.update_string(t, msg_bytes) if updated_old != updated_new: route_ok = False print(t, "Diff in seen") if updated_new != updated_string: route_ok = False print(t, "Diff in seen string") if dicts_vals_differ(parser_old.vl, parser_new.vl): print(t, "Diff in dict") route_ok = False if dicts_vals_differ(parser_new.vl, parser_string.vl): print(t, "Diff in dict string") route_ok = False return route_ok
def _create_radar_can_parser(): dbc_f = 'chrysler_pacifica_2017_hybrid_private_fusion.dbc' msg_n = len(RADAR_MSGS_C) # list of [(signal name, message name or number, initial values), (...)] # [('RADAR_STATE', 1024, 0), # ('LONG_DIST', 1072, 255), # ('LONG_DIST', 1073, 255), # ('LONG_DIST', 1074, 255), # ('LONG_DIST', 1075, 255), # The factor and offset are applied by the dbc parsing library, so the # default values should be after the factor/offset are applied. signals = list( zip( ['LONG_DIST'] * msg_n + ['LAT_DIST'] * msg_n + ['REL_SPEED'] * msg_n, RADAR_MSGS_C * 2 + # LONG_DIST, LAT_DIST RADAR_MSGS_D, # REL_SPEED [0] * msg_n + # LONG_DIST [-1000] * msg_n + # LAT_DIST [-146.278] * msg_n)) # REL_SPEED set to 0, factor/offset to this # TODO what are the checks actually used for? # honda only checks the last message, # toyota checks all the messages. Which do we want? checks = list( zip( RADAR_MSGS_C + RADAR_MSGS_D, [20] * msg_n + # 20Hz (0.05s) [20] * msg_n)) # 20Hz (0.05s) return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
def get_powertrain_can_parser(CP, canbus): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("LEFT_BLINKER", "Dashlights", 0), ("RIGHT_BLINKER", "Dashlights", 0), ("Steering_Angle", "Steering", 0), ("FL", "WHEEL_SPEEDS", 0), ("FR", "WHEEL_SPEEDS", 0), ("RL", "WHEEL_SPEEDS", 0), ("RR", "WHEEL_SPEEDS", 0), ("Steer_Torque_Sensor", "Steering_Torque", 0), ("Cruise_On", "CruiseControl", 0), ("Cruise_Activated", "CruiseControl", 0), ] checks = [ # sig_address, frequency ("Dashlights", 10), ("CruiseControl", 20), #remove("ES_Brake", 20), #remove("ES_RPM", 20), #remove("ES_LDW", 20), #remove("ES_CruiseThrottle", 20), ("Steering", 100), ("WHEEL_SPEEDS", 50), ("Steering_Torque", 100), ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, canbus.powertrain)
def get_can_parser2(CP): signals = [ ("Byte0", "LKAS11", 0), ("Byte1", "LKAS11", 0), ("Byte2", "LKAS11", 0), ("Byte3", "LKAS11", 0), ("Byte4", "LKAS11", 0), ("Byte5", "LKAS11", 0), ("Byte6", "LKAS11", 0), # Checksum ("Byte7", "LKAS11", 0), ("Byte0", "LKAS12", 0), ("Byte1", "LKAS12", 0), ("Byte2", "LKAS12", 0), ("Byte3", "LKAS12", 0), ("Byte4", "LKAS12", 0), ("Byte5", "LKAS12", 0) ] checks = [ ("LKAS11", 100), # LKAS11 = 100Hz ("LKAS12", 10) # LKAS12 = 10Hz ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 1)
def get_can_parser(CP): # this function generates lists for signal, messages and initial values if CP.carFingerprint == CAR.PRIUS: dbc_f = 'toyota_prius_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.RAV4H: dbc_f = 'toyota_rav4_hybrid_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.RAV4: dbc_f = 'toyota_rav4_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.COROLLA: dbc_f = 'toyota_corolla_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.LEXUS_RXH: dbc_f = 'lexus_rx_hybrid_2017_pt_generated.dbc' elif CP.carFingerprint == CAR.CAMRYH: dbc_f = 'toyota_camry_hybrid_2018_pt_generated.dbc' elif CP.carFingerprint == CAR.CAMRY: dbc_f = 'toyota_rav4_2017_pt_generated.dbc' signals = [ # sig_name, sig_address, default ("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_ANGLE", "STEER_ANGLE_SENSOR", 0), ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0), ("STEER_RATE", "STEER_ANGLE_SENSOR", 0), ("GAS_RELEASED", "PCM_CRUISE", 0), ("CRUISE_STATE", "PCM_CRUISE", 0), ("MAIN_ON", "PCM_CRUISE_2", 0), ("SET_SPEED", "PCM_CRUISE_2", 0), ("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 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), ("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), ("PCM_CRUISE_2", 33), ("STEER_TORQUE_SENSOR", 50), ("EPS_STATUS", 25), ] return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 0)
def _create_radard_can_parser(): dbc_f = 'teslaradar.dbc' msg_a_n = len(RADAR_A_MSGS) msg_b_n = len(RADAR_B_MSGS) signals = list( zip(['LongDist'] * msg_a_n + ['LatDist'] * msg_a_n + ['LongSpeed'] * msg_a_n + ['LongAccel'] * msg_a_n + ['Valid'] * msg_a_n + ['Tracked'] * msg_a_n + ['Meas'] * msg_a_n + ['ProbExist'] * msg_a_n + ['Index'] * msg_a_n + ['ProbObstacle'] * msg_a_n + ['LatSpeed'] * msg_b_n + ['Index2'] * msg_b_n + ['Class'] * msg_b_n + ['ProbClass'] * msg_b_n + ['Length'] * msg_b_n + ['dZ'] * msg_b_n + ['MovingState'] * msg_b_n, RADAR_A_MSGS * 10 + RADAR_B_MSGS * 7, [255.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + [0.] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0] * msg_a_n + [0.] * msg_a_n + [0] * msg_a_n + [0.] * msg_a_n + [0.] * msg_b_n + [0] * msg_b_n + [0] * msg_b_n + [0.] * msg_b_n + [0.] * msg_b_n + [0.] * msg_b_n + [0] * msg_b_n)) checks = list(zip(RADAR_A_MSGS + RADAR_B_MSGS, [6] * (msg_a_n + msg_b_n))) return CANParser( os.path.splitext(dbc_f)[0].encode('utf8'), signals, checks, 1)
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_PEDAL", "ACCEL_PEDAL_MSG", 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), ("INCREMENTING_220", "LKAS_INDICATOR_1", 0), ] checks = [ ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)
def get_camera_can_parser(CP): signals = [ ("Cruise_Set_Speed", "ES_DashStatus", 0), ("Counter", "ES_Distance", 0), ("Signal1", "ES_Distance", 0), ("Signal2", "ES_Distance", 0), ("Main", "ES_Distance", 0), ("Signal3", "ES_Distance", 0), ("Checksum", "ES_LKAS_State", 0), ("Counter", "ES_LKAS_State", 0), ("Keep_Hands_On_Wheel", "ES_LKAS_State", 0), ("Empty_Box", "ES_LKAS_State", 0), ("Signal1", "ES_LKAS_State", 0), ("LKAS_ACTIVE", "ES_LKAS_State", 0), ("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_ENABLE_2", "ES_LKAS_State", 0), ("Signal4", "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), ] checks = [ ("ES_DashStatus", 10), ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)
def get_powertrain_can_parser(CP): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("Steer_Torque_Sensor", "Steering_Torque", 0), ("Steering_Angle", "Steering_Torque", 0), ("Cruise_On", "CruiseControl", 0), ("Cruise_Activated", "CruiseControl", 0), ("Brake_Pedal", "Brake_Pedal", 0), ("Throttle_Pedal", "Throttle", 0), ("LEFT_BLINKER", "Dashlights", 0), ("RIGHT_BLINKER", "Dashlights", 0), ("SEATBELT_FL", "Dashlights", 0), ("FL", "Wheel_Speeds", 0), ("FR", "Wheel_Speeds", 0), ("RL", "Wheel_Speeds", 0), ("RR", "Wheel_Speeds", 0), ("DOOR_OPEN_FR", "BodyInfo", 1), ("DOOR_OPEN_FL", "BodyInfo", 1), ("DOOR_OPEN_RR", "BodyInfo", 1), ("DOOR_OPEN_RL", "BodyInfo", 1), ] checks = [ # sig_address, frequency ("Dashlights", 10), ("CruiseControl", 20), ("Wheel_Speeds", 50), ("Steering_Torque", 50), ("BodyInfo", 10), ] 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, timeout=100)
def get_cam_can_parser(CP, canbus): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default #("LINE1", "CAM_LANETRACK", 0), #("CTR", "CAM_LANETRACK", -1), #("LINE2", "CAM_LANETRACK", 0), #("LANE_CURVE", "CAM_LANETRACK", 0), #("SIG1", "CAM_LANETRACK", 0), #("SIG2", "CAM_LANETRACK", 0), #("ZERO", "CAM_LANETRACK", 0), #("SIG3", "CAM_LANETRACK", 0), #("CHKSUM", "CAM_LANETRACK", 0), ("LKAS_REQUEST", "CAM_LKAS", 0), ("CTR", "CAM_LKAS", -1), ("ERR_BIT_1", "CAM_LKAS", 0), ("LINE_NOT_VISIBLE", "CAM_LKAS", 0), ("BIT_1", "CAM_LKAS", 0), ("ERR_BIT_2", "CAM_LKAS", 0), ("BIT_2", "CAM_LKAS", 0), ("CHKSUM", "CAM_LKAS", 0), ("BIT2", "CAM_LANEINFO", 1), ("NO_ERR_BIT", "CAM_LANEINFO", 1), ("S1", "CAM_LANEINFO", 1), ("S1_NOT", "CAM_LANEINFO", 0), ] checks = [ # sig_address, frequency ("CAM_LKAS", 16), #("CAM_LANETRACK", 30), ("CAM_LANEINFO", 4), ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, canbus.cam)
def get_can_parser(CP): signals, checks = get_can_signals(CP) return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0, timeout=100)
def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("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), ("MAIN_ON", "PCM_CRUISE_2", 0), ("SET_SPEED", "PCM_CRUISE_2", 0), ("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 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), ("PCM_CRUISE_2", 33), ("STEER_TORQUE_SENSOR", 50), ("EPS_STATUS", 25), ] if CP.carFingerprint in TSS2_CAR: signals += [("STEER_ANGLE", "STEER_TORQUE_SENSOR", 0)] else: signals += [("STEER_ANGLE", "STEER_ANGLE_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 = [] # use steering message to check if panda is connected to frc checks = [("STEERING_LKA", 42)] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 2)
def get_chassis_can_parser(CP, canbus): # this function generates lists for signal, messages and initial values signals = [ # sig_name, sig_address, default ("FrictionBrakePressure", "EBCMFrictionBrakeStatus", 0), ] return CANParser(DBC[CP.carFingerprint]['chassis'], signals, [], canbus.chassis)
def _create_radard_can_parser(): dbc_f = 'ford_fusion_2018_adas.dbc' msg_n = len(RADAR_MSGS) signals = zip(['X_Rel'] * msg_n + ['Angle'] * msg_n + ['V_Rel'] * msg_n, RADAR_MSGS * 3, [0] * msg_n + [0] * msg_n + [0] * msg_n) checks = zip(RADAR_MSGS, [20] * msg_n) return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
def _create_radar_can_parser(car_fingerprint): dbc_f = DBC[car_fingerprint]['radar'] msg_n = len(RADAR_MSGS) signals = list( zip(['X_Rel'] * msg_n + ['Angle'] * msg_n + ['V_Rel'] * msg_n, RADAR_MSGS * 3, [0] * msg_n + [0] * msg_n + [0] * msg_n)) checks = list(zip(RADAR_MSGS, [20] * msg_n)) return CANParser(dbc_f, signals, checks, 1)
def get_can_parser(CP): # this function generates lists for signal, messages and initial values if CP.carFingerprint == CAR.PRIUS: dbc_f = 'toyota_prius_2017_pt.dbc' signals = [ ("GEAR", 295, 0), ("BRAKE_PRESSED", 550, 0), ("GAS_PEDAL", 581, 0), ] checks = [(550, 40), (581, 33)] elif CP.carFingerprint == CAR.RAV4: dbc_f = 'toyota_rav4_2017_pt.dbc' signals = [ ("GEAR", 956, 0x20), ("BRAKE_PRESSED", 548, 0), ("GAS_PEDAL", 705, 0), ] checks = [(548, 40), (705, 33)] # TODO: DOORS, GAS_PEDAL, BRAKE_PRESSED for RAV4 signals += [ # sig_name, sig_address, default ("WHEEL_SPEED_FL", 170, 0), ("WHEEL_SPEED_FR", 170, 0), ("WHEEL_SPEED_RL", 170, 0), ("WHEEL_SPEED_RR", 170, 0), ("DOOR_OPEN_FL", 1568, 1), ("DOOR_OPEN_FR", 1568, 1), ("DOOR_OPEN_RL", 1568, 1), ("DOOR_OPEN_RR", 1568, 1), ("SEATBELT_DRIVER_UNLATCHED", 1568, 1), ("TC_DISABLED", 951, 1), ("STEER_ANGLE", 37, 0), ("STEER_FRACTION", 37, 0), ("STEER_RATE", 37, 0), ("GAS_RELEASED", 466, 0), ("CRUISE_STATE", 466, 0), ("MAIN_ON", 467, 0), ("SET_SPEED", 467, 0), ("LOW_SPEED_LOCKOUT", 467, 0), ("STEER_TORQUE_DRIVER", 608, 0), ("STEER_TORQUE_EPS", 608, 0), ("TURN_SIGNALS", 1556, 3), # 3 is no blinkers ("LKA_STATE", 610, 0), ("BRAKE_LIGHTS_ACC", 951, 0), ] checks += [ (170, 80), (37, 80), (466, 33), (467, 33), (608, 50), (610, 25), ] return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 0)
def get_can_parser(CP): #2018.09.04 combine in above signals, checks = get_can_signals(CP) #2018.09.06 add two argument #canbus.powertrain is can 0 (bus 0) # print ("carstate.py signals") #print (signals) # print (checks) #print("carstate.py") # print(DBC[CP.carFingerprint]['pt']) return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0) #2018.09.06 4:37PM change canbuspowertrain to 0
def _create_radard_can_parser(): dbc_f = 'toyota_prius_2017_adas.dbc' msg_n = len(RADAR_MSGS) signals = zip(['LONG_DIST'] * msg_n + ['NEW_TRACK'] * msg_n + ['LAT_DIST'] * msg_n + ['REL_SPEED'] * msg_n + ['VALID'] * msg_n, RADAR_MSGS * 5, [255] * msg_n + [1] * msg_n + [0] * msg_n + [0] * msg_n + [0] * msg_n) checks = zip(RADAR_MSGS, [20]*msg_n) return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
def _create_nidec_can_parser(): dbc_f = 'acura_ilx_2016_nidec.dbc' radar_messages = [0x400] + range(0x430, 0x43A) + range(0x440, 0x446) signals = zip(['RADAR_STATE'] + ['LONG_DIST'] * 16 + ['NEW_TRACK'] * 16 + ['LAT_DIST'] * 16 + ['REL_SPEED'] * 16, [0x400] + radar_messages[1:] * 4, [0] + [255] * 16 + [1] * 16 + [0] * 16 + [0] * 16) checks = zip([0x445], [20]) return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
def get_cam_can_parser(CP): signals = [] # 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)
def get_cam_can_parser(CP): signals = [] # all hondas except CRV and RDX use 0xe4 for steering checks = [(0xe4, 100)] if CP.carFingerprint in [CAR.CRV, CAR.ACURA_RDX]: checks = [(0x194, 100)] cam_bus = 1 if CP.carFingerprint in HONDA_BOSCH else 2 return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, cam_bus)
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)
def test_subaru(self): # Subuaru is little endian CP = SubaruInterface.get_params(SUBARU_CAR.IMPREZA) signals = [ ("Counter", "ES_LKAS", 0), ("LKAS_Output", "ES_LKAS", 0), ("LKAS_Request", "ES_LKAS", 0), ("SET_1", "ES_LKAS", 0), ] checks = [] parser = CANParser(SUBARU_DBC[CP.carFingerprint]['pt'], signals, checks, 0) packer = CANPacker(SUBARU_DBC[CP.carFingerprint]['pt']) idx = 0 for steer in range(0, 255): for active in [1, 0]: values = { "Counter": idx, "LKAS_Output": steer, "LKAS_Request": active, "SET_1": 1 } msgs = packer.make_can_msg("ES_LKAS", 0, values) bts = can_list_to_can_capnp([msgs]) parser.update_string(bts) self.assertAlmostEqual(parser.vl["ES_LKAS"]["LKAS_Output"], steer) self.assertAlmostEqual(parser.vl["ES_LKAS"]["LKAS_Request"], active) self.assertAlmostEqual(parser.vl["ES_LKAS"]["SET_1"], 1) self.assertAlmostEqual(parser.vl["ES_LKAS"]["Counter"], idx % 16) idx += 1
def _create_radard_can_parser(): dbc_f = 'toyota_prius_2017_adas.dbc' radar_messages = range(0x210, 0x220) msg_n = len(radar_messages) msg_last = radar_messages[-1] signals = zip( ['LONG_DIST'] * msg_n + ['NEW_TRACK'] * msg_n + ['LAT_DIST'] * msg_n + ['REL_SPEED'] * msg_n + ['VALID'] * msg_n, radar_messages * 5, [255] * msg_n + [1] * msg_n + [0] * msg_n + [0] * msg_n + [0] * msg_n) checks = zip(radar_messages, [20] * msg_n) return CANParser(os.path.splitext(dbc_f)[0], signals, checks, 1)
def get_cam_can_parser(CP): signals = [] # all hondas except CRV and RDX use 0xe4 for steering checks = [(0xe4, 100)] #if CP.carFingerprint in [CAR.CRV, CAR.ACURA_RDX]: # checks = [(0x194, 100)] # cam_bus = 1 if CP.carFingerprint in HONDA_BOSCH else 2 cam_bus = 2 # le macchina envoie sur le bus 2 du panda l'id 0xe4 return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, cam_bus)
def get_radar_can_parser(CP): signals = [ # sig_name, sig_address, default ("ACC_ObjStatus", "SCC11", 0), ("ACC_ObjLatPos", "SCC11", 0), ("ACC_ObjDist", "SCC11", 0), ("ACC_ObjRelSpd", "SCC11", 0), ] checks = [ # address, frequency ("SCC11", 50), ] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)
def get_can_parser(CP): signals = [ # sig_name, sig_address, default ("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_ANGLE", "STEER_ANGLE_SENSOR", 0), ("STEER_FRACTION", "STEER_ANGLE_SENSOR", 0), ("STEER_RATE", "STEER_ANGLE_SENSOR", 0), ("GAS_RELEASED", "PCM_CRUISE", 0), ("CRUISE_STATE", "PCM_CRUISE", 0), ("MAIN_ON", "PCM_CRUISE_2", 0), ("SET_SPEED", "PCM_CRUISE_2", 0), ("LOW_SPEED_LOCKOUT", "PCM_CRUISE_2", 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), ("PCM_CRUISE_2", 33), ("STEER_TORQUE_SENSOR", 50), ("EPS_STATUS", 25), ] if CP.carFingerprint in [CAR.PRIUS, CAR.PRIUS_PRIME]: signals += [("STATE", "AUTOPARK_STATUS", 0)] return CANParser(DBC[CP.carFingerprint]['pt'], signals, checks, 0)