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

Honda: add odyssey RC5(japan special) support #2099

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions board/safety/safety_honda.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static bool honda_alt_brake_msg = false;
static bool honda_fwd_brake = false;
static bool honda_bosch_long = false;
static bool honda_bosch_radarless = false;
static bool honda_bosch_scm_alt = false;
typedef enum {HONDA_NIDEC, HONDA_BOSCH} HondaHw;
static HondaHw honda_hw = HONDA_NIDEC;

Expand Down Expand Up @@ -87,8 +88,18 @@ static void honda_rx_hook(const CANPacket_t *to_push) {

// check ACC main state
// 0x326 for all Bosch and some Nidec, 0x1A6 for some Nidec
if ((addr == 0x326) || (addr == 0x1A6)) {
acc_main_on = GET_BIT(to_push, ((addr == 0x326) ? 28U : 47U));
// Odyssey RC5 japanese type use 0x1a6 for scm_buttons and main_on signal
// But 0x326 also exist. So we need to ignore it.
if (addr == 0x1A6) {
honda_bosch_scm_alt = true;
acc_main_on = GET_BIT(to_push, 47U);
if (!acc_main_on) {
controls_allowed = false;
}
}

if ((addr == 0x326) && (!honda_bosch_scm_alt)) {
acc_main_on = GET_BIT(to_push, 28U);
if (!acc_main_on) {
controls_allowed = false;
}
Expand Down Expand Up @@ -127,6 +138,7 @@ static void honda_rx_hook(const CANPacket_t *to_push) {
controls_allowed = false;
}
cruise_button_prev = button;

}

// user brake signal on 0x17C reports applied brake from computer brake on accord
Expand Down Expand Up @@ -286,7 +298,7 @@ static bool honda_tx_hook(const CANPacket_t *to_send) {
// FORCE CANCEL: safety check only relevant when spamming the cancel button in Bosch HW
// ensuring that only the cancel button press is sent (VAL 2) when controls are off.
// This avoids unintended engagements while still allowing resume spam
if ((addr == 0x296) && !controls_allowed && (bus == bus_buttons)) {
if (((addr == 0x296) || (addr == 0x1A6)) && !controls_allowed && (bus == bus_buttons)) {
if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) {
tx = false;
}
Expand Down Expand Up @@ -314,6 +326,7 @@ static safety_config honda_nidec_init(uint16_t param) {
honda_alt_brake_msg = false;
honda_bosch_long = false;
honda_bosch_radarless = false;
honda_bosch_scm_alt = false;

safety_config ret;

Expand All @@ -338,7 +351,7 @@ static safety_config honda_nidec_init(uint16_t param) {
static safety_config honda_bosch_init(uint16_t param) {
static CanMsg HONDA_BOSCH_TX_MSGS[] = {{0xE4, 0, 5}, {0xE5, 0, 8}, {0x296, 1, 4}, {0x33D, 0, 5}, {0x33DA, 0, 5}, {0x33DB, 0, 8}}; // Bosch
static CanMsg HONDA_BOSCH_LONG_TX_MSGS[] = {{0xE4, 1, 5}, {0x1DF, 1, 8}, {0x1EF, 1, 8}, {0x1FA, 1, 8}, {0x30C, 1, 8}, {0x33D, 1, 5}, {0x33DA, 1, 5}, {0x33DB, 1, 8}, {0x39F, 1, 8}, {0x18DAB0F1, 1, 8}}; // Bosch w/ gas and brakes
static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x33D, 0, 8}}; // Bosch radarless
static CanMsg HONDA_RADARLESS_TX_MSGS[] = {{0xE4, 0, 5}, {0x296, 2, 4}, {0x1A6, 2, 8},{0x33D, 0, 8}}; // Bosch radarless
static CanMsg HONDA_RADARLESS_LONG_TX_MSGS[] = {{0xE4, 0, 5}, {0x33D, 0, 8}, {0x1C8, 0, 8}, {0x30C, 0, 8}}; // Bosch radarless w/ gas and brakes

const uint16_t HONDA_PARAM_ALT_BRAKE = 1;
Expand All @@ -364,6 +377,7 @@ static safety_config honda_bosch_init(uint16_t param) {
honda_bosch_radarless = GET_FLAG(param, HONDA_PARAM_RADARLESS);
// Checking for alternate brake override from safety parameter
honda_alt_brake_msg = GET_FLAG(param, HONDA_PARAM_ALT_BRAKE);
honda_bosch_scm_alt = false;

// radar disabled so allow gas/brakes
#ifdef ALLOW_DEBUG
Expand Down
11 changes: 11 additions & 0 deletions tests/safety/test_honda.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ def setUp(self):
self.safety.init_tests()


class TestHondaBoschRadarlessAltSCMSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase):
"""
Covers the Honda Bosch Radarless safety mode with stock longitudinal and an alternate SCM message
"""

def setUp(self):
super().setUp()
self.safety.set_safety_hooks(Panda.SAFETY_HONDA_BOSCH, Panda.FLAG_HONDA_RADARLESS | Panda.FLAG_HONDA_NIDEC_ALT)
self.safety.init_tests()


class TestHondaBoschRadarlessAltBrakeSafety(HondaPcmEnableBase, TestHondaBoschRadarlessSafetyBase, TestHondaBoschAltBrakeSafetyBase):
"""
Covers the Honda Bosch Radarless safety mode with stock longitudinal and an alternate brake message
Expand Down
Loading