这是indexloc提供的服务,不要输入任何密码
Skip to content
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
5 changes: 5 additions & 0 deletions opendbc/safety/safety/safety_hyundai_canfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) {
violation |= longitudinal_accel_checks(desired_accel_val, HYUNDAI_LONG_LIMITS);
} else {
// only used to cancel on here
const int acc_mode = (GET_BYTE(to_send, 8) >> 4) & 0x7U;
if (acc_mode != 4) {
violation = true;
}

if ((desired_accel_raw != 0) || (desired_accel_val != 0)) {
violation = true;
}
Expand Down
12 changes: 12 additions & 0 deletions opendbc/safety/tests/test_hyundai_canfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def _button_msg(self, buttons, main_button=0, bus=1):
}
return self.packer.make_can_msg_panda("CRUISE_BUTTONS_ALT", self.PT_BUS, values)

def _acc_cancel_msg(self, cancel, accel=0):
values = {"ACCMode": 4 if cancel else 0, "aReqRaw": accel, "aReqValue": accel}
return self.packer.make_can_msg_panda("SCC_CONTROL", self.PT_BUS, values)

def test_button_sends(self):
"""
No button send allowed with alt buttons.
Expand All @@ -161,6 +165,14 @@ def test_button_sends(self):
self.safety.set_controls_allowed(enabled)
self.assertFalse(self._tx(self._button_msg(btn)))

def test_acc_cancel(self):
# FIXME: the CANFD_ALT_BUTTONS cars are the only ones that use SCC_CONTROL to cancel, why can't we use buttons?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunnyhaibin know anything about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sunnyhaibin can you test sending the buttons to simplify this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sshane For cars with only CRUISE_BUTTONS_ALT/0x1AA, I have tried sending the PAUSE/RESUME button via CRUISE_BUTTONS_ALT/0x1AA (bus 0, 1, 2, respectively), and the car did not respond at all to our cancel command.

for enabled in (True, False):
self.safety.set_controls_allowed(enabled)
self.assertTrue(self._tx(self._acc_cancel_msg(True)))
self.assertFalse(self._tx(self._acc_cancel_msg(True, accel=1)))
self.assertFalse(self._tx(self._acc_cancel_msg(False)))


class TestHyundaiCanfdLKASteeringEV(TestHyundaiCanfdBase):

Expand Down