Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CANParser: consistent style for adding signals/checks #23646

Merged
merged 2 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion selfdrive/car/chrysler/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_can_parser(CP):
("BLIND_SPOT_RIGHT", "BLIND_SPOT_WARNINGS"),
("BLIND_SPOT_LEFT", "BLIND_SPOT_WARNINGS"),
]
checks += [("BLIND_SPOT_WARNINGS", 2)]
checks.append(("BLIND_SPOT_WARNINGS", 2))

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

Expand Down
8 changes: 2 additions & 6 deletions selfdrive/car/gm/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,8 @@ def get_can_parser(CP):
]

if CP.carFingerprint == CAR.VOLT:
signals += [
("RegenPaddle", "EBCMRegenPaddle"),
]
checks += [
("EBCMRegenPaddle", 50),
]
signals.append(("RegenPaddle", "EBCMRegenPaddle"))
checks.append(("EBCMRegenPaddle", 50))

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, CanBus.POWERTRAIN)

Expand Down
26 changes: 11 additions & 15 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,13 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
]

if CP.carFingerprint in (CAR.CRV_HYBRID, CAR.CIVIC_BOSCH_DIESEL, CAR.ACURA_RDX_3G, CAR.HONDA_E):
checks += [
(gearbox_msg, 50),
]
checks.append((gearbox_msg, 50))
else:
checks += [
(gearbox_msg, 100),
]
checks.append((gearbox_msg, 100))

if CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL:
signals += [("BRAKE_PRESSED", "BRAKE_MODULE", 0)]
checks += [("BRAKE_MODULE", 50)]
signals.append(("BRAKE_PRESSED", "BRAKE_MODULE", 0))
checks.append(("BRAKE_MODULE", 50))

if CP.carFingerprint in HONDA_BOSCH:
signals += [
Expand Down Expand Up @@ -103,14 +99,14 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
("CRUISE_SPEED_OFFSET", "CRUISE_PARAMS", 0)]

if CP.carFingerprint == CAR.ODYSSEY_CHN:
checks += [("CRUISE_PARAMS", 10)]
checks.append(("CRUISE_PARAMS", 10))
else:
checks += [("CRUISE_PARAMS", 50)]
checks.append(("CRUISE_PARAMS", 50))

if CP.carFingerprint in (CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E):
signals += [("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1)]
signals.append(("DRIVERS_DOOR_OPEN", "SCM_FEEDBACK", 1))
elif CP.carFingerprint == CAR.ODYSSEY_CHN:
signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1)]
signals.append(("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1))
elif CP.carFingerprint in (CAR.FREED, CAR.HRV):
signals += [("DRIVERS_DOOR_OPEN", "SCM_BUTTONS", 1),
("WHEELS_MOVING", "STANDSTILL", 1)]
Expand All @@ -133,8 +129,8 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
("EPB_STATUS", 50),
]
elif CP.carFingerprint in (CAR.ODYSSEY, CAR.ODYSSEY_CHN):
signals += [("EPB_STATE", "EPB_STATUS", 0)]
checks += [("EPB_STATUS", 50)]
signals.append(("EPB_STATE", "EPB_STATUS", 0))
checks.append(("EPB_STATUS", 50))

# add gas interceptor reading if we are using it
if CP.enableGasInterceptor:
Expand All @@ -147,7 +143,7 @@ def get_can_signals(CP, gearbox_msg, main_on_sig_msg):
("BRAKE_ERROR_1", "STANDSTILL", 1),
("BRAKE_ERROR_2", "STANDSTILL", 1)
]
checks += [("STANDSTILL", 50)]
checks.append(("STANDSTILL", 50))

return signals, checks

Expand Down
44 changes: 13 additions & 31 deletions selfdrive/car/hyundai/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def get_can_parser(CP):
("FCA_CmdAct", "FCA11"),
("CF_VSM_Warn", "FCA11"),
]
checks += [("FCA11", 50)]
checks.append(("FCA11", 50))
else:
signals += [
("AEB_CmdAct", "SCC12"),
Expand All @@ -218,20 +218,14 @@ def get_can_parser(CP):
("CF_Lca_IndLeft", "LCA11"),
("CF_Lca_IndRight", "LCA11"),
]
checks += [("LCA11", 50)]
checks.append(("LCA11", 50))

if CP.carFingerprint in (HYBRID_CAR | EV_CAR):
if CP.carFingerprint in HYBRID_CAR:
signals += [
("CR_Vcu_AccPedDep_Pos", "E_EMS11")
]
signals.append(("CR_Vcu_AccPedDep_Pos", "E_EMS11"))
else:
signals += [
("Accel_Pedal_Pos", "E_EMS11")
]
checks += [
("E_EMS11", 50),
]
signals.append(("Accel_Pedal_Pos", "E_EMS11"))
checks.append(("E_EMS11", 50))
else:
signals += [
("PV_AV_CAN", "EMS12"),
Expand All @@ -243,29 +237,17 @@ def get_can_parser(CP):
]

if CP.carFingerprint in FEATURES["use_cluster_gears"]:
signals += [
("CF_Clu_Gear", "CLU15"),
]
checks += [
("CLU15", 5)
]
signals.append(("CF_Clu_Gear", "CLU15"))
checks.append(("CLU15", 5))
elif CP.carFingerprint in FEATURES["use_tcu_gears"]:
signals += [
("CUR_GR", "TCU12")
]
checks += [
("TCU12", 100)
]
signals.append(("CUR_GR", "TCU12"))
checks.append(("TCU12", 100))
elif CP.carFingerprint in FEATURES["use_elect_gears"]:
signals += [("Elect_Gear_Shifter", "ELECT_GEAR")]
checks += [("ELECT_GEAR", 20)]
signals.append(("Elect_Gear_Shifter", "ELECT_GEAR"))
checks.append(("ELECT_GEAR", 20))
else:
signals += [
("CF_Lvr_Gear", "LVR12")
]
checks += [
("LVR12", 100)
]
signals.append(("CF_Lvr_Gear", "LVR12"))
checks.append(("LVR12", 100))

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

Expand Down
24 changes: 6 additions & 18 deletions selfdrive/car/nissan/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,8 @@ def get_can_parser(CP):
]
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 1)

signals += [
("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR"),
]
checks += [
("STEER_TORQUE_SENSOR", 100),
]
signals.append(("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR"))
checks.append(("STEER_TORQUE_SENSOR", 100))

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

Expand Down Expand Up @@ -345,19 +341,11 @@ def get_cam_can_parser(CP):
checks = []

if CP.carFingerprint in (CAR.ROGUE, CAR.XTRAIL):
signals += [
("CRUISE_ON", "PRO_PILOT"),
]
checks += [
("PRO_PILOT", 100),
]
signals.append(("CRUISE_ON", "PRO_PILOT"))
checks.append(("PRO_PILOT", 100))
elif CP.carFingerprint == CAR.ALTIMA:
signals += [
("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR"),
]
checks += [
("STEER_TORQUE_SENSOR", 100),
]
signals.append(("STEER_TORQUE_DRIVER", "STEER_TORQUE_SENSOR"))
checks.append(("STEER_TORQUE_SENSOR", 100))
return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 0)

return CANParser(DBC[CP.carFingerprint]["pt"], signals, checks, 1)
12 changes: 3 additions & 9 deletions selfdrive/car/subaru/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ def get_can_parser(CP):
("L_APPROACHING", "BSD_RCTA"),
("R_APPROACHING", "BSD_RCTA"),
]
checks += [
("BSD_RCTA", 17),
]
checks.append(("BSD_RCTA", 17))

if CP.carFingerprint not in PREGLOBAL_CARS:
signals += [
Expand All @@ -137,13 +135,9 @@ def get_can_parser(CP):
("CruiseControl", 20),
]
else:
signals += [
("UNITS", "Dash_State2"),
]
signals.append(("UNITS", "Dash_State2"))

checks += [
("Dash_State2", 1),
]
checks.append(("Dash_State2", 1))

if CP.carFingerprint == CAR.FORESTER_PREGLOBAL:
checks += [
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/toyota/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ def get_can_parser(CP):
("R_ADJACENT", "BSM", 0),
("R_APPROACHING", "BSM", 0),
]
checks += [
("BSM", 1)
]
checks.append(("BSM", 1))

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

Expand Down
10 changes: 5 additions & 5 deletions selfdrive/car/volkswagen/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,15 @@ def get_can_parser(CP):
]

if CP.transmissionType == TransmissionType.automatic:
signals += [("GE_Fahrstufe", "Getriebe_11")] # Auto trans gear selector position
checks += [("Getriebe_11", 20)] # From J743 Auto transmission control module
signals.append(("GE_Fahrstufe", "Getriebe_11")) # Auto trans gear selector position
checks.append(("Getriebe_11", 20)) # From J743 Auto transmission control module
elif CP.transmissionType == TransmissionType.direct:
signals += [("GearPosition", "EV_Gearshift")] # EV gear selector position
checks += [("EV_Gearshift", 10)] # From J??? unknown EV control module
signals.append(("GearPosition", "EV_Gearshift")) # EV gear selector position
checks.append(("EV_Gearshift", 10)) # From J??? unknown EV control module
elif CP.transmissionType == TransmissionType.manual:
signals += [("MO_Kuppl_schalter", "Motor_14"), # Clutch switch
("BCM1_Rueckfahrlicht_Schalter", "Gateway_72")] # Reverse light from BCM
checks += [("Motor_14", 10)] # From J623 Engine control module
checks.append(("Motor_14", 10)) # From J623 Engine control module

if CP.networkLocation == NetworkLocation.fwdCamera:
# Radars are here on CANBUS.pt
Expand Down