Skip to content

Commit

Permalink
Ford: long safety is default for CAN (#2128)
Browse files Browse the repository at this point in the history
* ford long safety

* same with ford_longitudinal

* Update tests/safety/test_ford.py
  • Loading branch information
sshane authored Jan 23, 2025
1 parent 73dbcaa commit 1290588
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
4 changes: 4 additions & 0 deletions board/safety/safety_ford.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,9 @@ static safety_config ford_init(uint16_t param) {
ford_canfd = GET_FLAG(param, FORD_PARAM_CANFD);
#endif

// Longitudinal is the default for CAN, and optional for CAN FD w/ ALLOW_DEBUG
ford_longitudinal = !ford_canfd || ford_longitudinal;

safety_config ret;
// FIXME: cppcheck thinks that ford_canfd is always false. This is not true
// if ALLOW_DEBUG is defined but cppcheck is run without ALLOW_DEBUG
Expand All @@ -408,6 +411,7 @@ static safety_config ford_init(uint16_t param) {
ret = ford_longitudinal ? BUILD_SAFETY_CFG(ford_rx_checks, FORD_CANFD_LONG_TX_MSGS) : \
BUILD_SAFETY_CFG(ford_rx_checks, FORD_CANFD_STOCK_TX_MSGS);
} else {
// cppcheck-suppress knownConditionTrueFalse
ret = ford_longitudinal ? BUILD_SAFETY_CFG(ford_rx_checks, FORD_LONG_TX_MSGS) : \
BUILD_SAFETY_CFG(ford_rx_checks, FORD_STOCK_TX_MSGS);
}
Expand Down
19 changes: 2 additions & 17 deletions tests/safety/test_ford.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ class Buttons:


# Ford safety has four different configurations tested here:
# * CAN with stock longitudinal
# * CAN with openpilot longitudinal
# * CAN FD with stock longitudinal
# * CAN FD with openpilot longitudinal
Expand Down Expand Up @@ -355,21 +354,6 @@ def test_acc_buttons(self):
self.assertEqual(enabled, self._tx(self._acc_button_msg(Buttons.CANCEL, bus)))


class TestFordStockSafety(TestFordSafetyBase):
STEER_MESSAGE = MSG_LateralMotionControl

TX_MSGS = [
[MSG_Steering_Data_FD1, 0], [MSG_Steering_Data_FD1, 2], [MSG_ACCDATA_3, 0], [MSG_Lane_Assist_Data1, 0],
[MSG_LateralMotionControl, 0], [MSG_IPMA_Data, 0],
]

def setUp(self):
self.packer = CANPackerPanda("ford_lincoln_base_pt")
self.safety = libpanda_py.libpanda
self.safety.set_safety_hooks(Panda.SAFETY_FORD, 0)
self.safety.init_tests()


class TestFordCANFDStockSafety(TestFordSafetyBase):
STEER_MESSAGE = MSG_LateralMotionControl2

Expand Down Expand Up @@ -457,7 +441,8 @@ class TestFordLongitudinalSafety(TestFordLongitudinalSafetyBase):
def setUp(self):
self.packer = CANPackerPanda("ford_lincoln_base_pt")
self.safety = libpanda_py.libpanda
self.safety.set_safety_hooks(Panda.SAFETY_FORD, Panda.FLAG_FORD_LONG_CONTROL)
# Make sure we enforce long safety even without long flag for CAN
self.safety.set_safety_hooks(Panda.SAFETY_FORD, 0)
self.safety.init_tests()


Expand Down

0 comments on commit 1290588

Please sign in to comment.