Skip to content

Commit

Permalink
Honda Bosch: detect alternate brake signal (commaai#31500)
Browse files Browse the repository at this point in the history
* Do Accord

* add comment

* good test

* this catches the accord/accordh issue!

* as expected, only if both radar&camera have in common FW does the test fail

* cmt

* clean up

* better

* Use HondaFlags

* detect alt brake

* for test

* hypothesis isn't installed

* test failure

* works

* Revert " works"

This reverts commit bfc0d80.

* Revert "test failure"

This reverts commit 10ab6eb.

* Revert "hypothesis isn't installed"

This reverts commit d474cc3.

* Revert "for test"

This reverts commit 98e039f.

* this is important too

* clean up

* more clean up

* Update ref_commit
  • Loading branch information
sshane authored Feb 17, 2024
1 parent 62f4eec commit 2e8c623
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/car_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def fingerprint(logcan, sendcan, num_pandas):
cloudlog.warning("VIN %s", vin)
params.put("CarVin", vin)

# disable OBD multiplexing for potential ECU knockouts
# disable OBD multiplexing for CAN fingerprinting and potential ECU knockouts
set_obd_multiplexing(params, False)
params.put_bool("FirmwareQueryDone", True)

Expand Down
8 changes: 4 additions & 4 deletions selfdrive/car/honda/carstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from opendbc.can.parser import CANParser
from openpilot.selfdrive.car.honda.hondacan import get_cruise_speed_conversion, get_pt_bus
from openpilot.selfdrive.car.honda.values import CAR, DBC, STEER_THRESHOLD, HONDA_BOSCH, \
HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_ALT_BRAKE_SIGNAL, \
HONDA_BOSCH_RADARLESS
HONDA_NIDEC_ALT_SCM_MESSAGES, HONDA_BOSCH_RADARLESS, \
HondaFlags
from openpilot.selfdrive.car.interfaces import CarStateBase

TransmissionType = car.CarParams.TransmissionType
Expand Down Expand Up @@ -44,7 +44,7 @@ def get_can_messages(CP, gearbox_msg):
else:
messages.append((gearbox_msg, 100))

if CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL:
if CP.flags & HondaFlags.BOSCH_ALT_BRAKE:
messages.append(("BRAKE_MODULE", 50))

if CP.carFingerprint in (HONDA_BOSCH | {CAR.CIVIC, CAR.ODYSSEY, CAR.ODYSSEY_CHN}):
Expand Down Expand Up @@ -217,7 +217,7 @@ def update(self, cp, cp_cam, cp_body):
else:
ret.cruiseState.speed = cp.vl["CRUISE"]["CRUISE_SPEED_PCM"] * CV.KPH_TO_MS

if self.CP.carFingerprint in HONDA_BOSCH_ALT_BRAKE_SIGNAL:
if self.CP.flags & HondaFlags.BOSCH_ALT_BRAKE:
ret.brakePressed = cp.vl["BRAKE_MODULE"]["BRAKE_PRESSED"] != 0
else:
# brake switch has shown some single time step noise, so only considered when
Expand Down
6 changes: 4 additions & 2 deletions selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
from panda import Panda
from openpilot.common.conversions import Conversions as CV
from openpilot.common.numpy_fast import interp
from openpilot.selfdrive.car.honda.hondacan import get_pt_bus
from openpilot.selfdrive.car.honda.values import CarControllerParams, CruiseButtons, HondaFlags, CAR, HONDA_BOSCH, HONDA_NIDEC_ALT_SCM_MESSAGES, \
HONDA_BOSCH_ALT_BRAKE_SIGNAL, HONDA_BOSCH_RADARLESS
HONDA_BOSCH_RADARLESS
from openpilot.selfdrive.car import create_button_events, get_safety_config
from openpilot.selfdrive.car.interfaces import CarInterfaceBase
from openpilot.selfdrive.car.disable_ecu import disable_ecu
Expand Down Expand Up @@ -275,7 +276,8 @@ def _get_params(ret, candidate, fingerprint, car_fw, experimental_long, docs):
raise ValueError(f"unsupported car {candidate}")

# These cars use alternate user brake msg (0x1BE)
if candidate in HONDA_BOSCH_ALT_BRAKE_SIGNAL:
if 0x1BE in fingerprint[get_pt_bus(candidate)] and candidate in HONDA_BOSCH:
ret.flags |= HondaFlags.BOSCH_ALT_BRAKE.value
ret.safetyConfigs[0].safetyParam |= Panda.FLAG_HONDA_ALT_BRAKE

# These cars use alternate SCM messages (SCM_FEEDBACK AND SCM_BUTTON)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/honda/values.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, CP):
class HondaFlags(IntFlag):
# Bosch models with alternate set of LKAS_HUD messages
BOSCH_EXT_HUD = 1
BOSCH_ALT_BRAKE = 2


# Car button codes
Expand Down Expand Up @@ -252,5 +253,4 @@ def init_make(self, CP: car.CarParams):
CAR.PILOT, CAR.RIDGELINE}
HONDA_BOSCH = {CAR.ACCORD, CAR.ACCORDH, CAR.CIVIC_BOSCH, CAR.CIVIC_BOSCH_DIESEL, CAR.CRV_5G,
CAR.CRV_HYBRID, CAR.INSIGHT, CAR.ACURA_RDX_3G, CAR.HONDA_E, CAR.CIVIC_2022, CAR.HRV_3G}
HONDA_BOSCH_ALT_BRAKE_SIGNAL = {CAR.ACCORD, CAR.CRV_5G, CAR.ACURA_RDX_3G, CAR.HRV_3G}
HONDA_BOSCH_RADARLESS = {CAR.CIVIC_2022, CAR.HRV_3G}
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/ref_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7d25b1f7d0bd3b506fa4e72ff893728894eb1a45
1b16593e2d0c9ff2dae2916293ae5fbc7d6f26df

0 comments on commit 2e8c623

Please sign in to comment.