Skip to content

Commit

Permalink
Subaru: add new angle LKAS message definitions (#1602)
Browse files Browse the repository at this point in the history
* just add the lkas message to start

* added to tests too

* default parameter
  • Loading branch information
jnewb1 authored Aug 23, 2023
1 parent ee2f9df commit 04df95d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions board/safety/safety_subaru.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const LongitudinalLimits SUBARU_LONG_LIMITS = {
#define MSG_SUBARU_Wheel_Speeds 0x13a

#define MSG_SUBARU_ES_LKAS 0x122
#define MSG_SUBARU_ES_LKAS_ANGLE 0x124
#define MSG_SUBARU_ES_Brake 0x220
#define MSG_SUBARU_ES_Distance 0x221
#define MSG_SUBARU_ES_Status 0x222
Expand All @@ -42,7 +43,7 @@ const LongitudinalLimits SUBARU_LONG_LIMITS = {
#define SUBARU_ALT_BUS 1
#define SUBARU_CAM_BUS 2

#define SUBARU_COMMON_TX_MSGS(alt_bus) \
#define SUBARU_COMMON_TX_MSGS(alt_bus, lkas_msg) \
{MSG_SUBARU_ES_LKAS, SUBARU_MAIN_BUS, 8}, \
{MSG_SUBARU_ES_Distance, alt_bus, 8}, \
{MSG_SUBARU_ES_DashStatus, SUBARU_MAIN_BUS, 8}, \
Expand All @@ -61,18 +62,18 @@ const LongitudinalLimits SUBARU_LONG_LIMITS = {
{.msg = {{MSG_SUBARU_CruiseControl, alt_bus, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 50000U}, { 0 }, { 0 }}}, \

const CanMsg SUBARU_TX_MSGS[] = {
SUBARU_COMMON_TX_MSGS(SUBARU_MAIN_BUS)
SUBARU_COMMON_TX_MSGS(SUBARU_MAIN_BUS, MSG_SUBARU_ES_LKAS)
};
#define SUBARU_TX_MSGS_LEN (sizeof(SUBARU_TX_MSGS) / sizeof(SUBARU_TX_MSGS[0]))

const CanMsg SUBARU_LONG_TX_MSGS[] = {
SUBARU_COMMON_TX_MSGS(SUBARU_MAIN_BUS)
SUBARU_COMMON_TX_MSGS(SUBARU_MAIN_BUS, MSG_SUBARU_ES_LKAS)
SUBARU_COMMON_LONG_TX_MSGS(SUBARU_MAIN_BUS)
};
#define SUBARU_LONG_TX_MSGS_LEN (sizeof(SUBARU_LONG_TX_MSGS) / sizeof(SUBARU_LONG_TX_MSGS[0]))

const CanMsg SUBARU_GEN2_TX_MSGS[] = {
SUBARU_COMMON_TX_MSGS(SUBARU_ALT_BUS)
SUBARU_COMMON_TX_MSGS(SUBARU_ALT_BUS, MSG_SUBARU_ES_LKAS)
};
#define SUBARU_GEN2_TX_MSGS_LEN (sizeof(SUBARU_GEN2_TX_MSGS) / sizeof(SUBARU_GEN2_TX_MSGS[0]))

Expand Down
9 changes: 5 additions & 4 deletions tests/safety/test_subaru.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
MSG_SUBARU_Steering_Torque = 0x119
MSG_SUBARU_Wheel_Speeds = 0x13a
MSG_SUBARU_ES_LKAS = 0x122
MSG_SUBARU_ES_LKAS_ANGLE = 0x124
MSG_SUBARU_ES_Brake = 0x220
MSG_SUBARU_ES_Distance = 0x221
MSG_SUBARU_ES_Status = 0x222
Expand All @@ -25,8 +26,8 @@
SUBARU_CAM_BUS = 2


def lkas_tx_msgs(alt_bus):
return [[MSG_SUBARU_ES_LKAS, SUBARU_MAIN_BUS],
def lkas_tx_msgs(alt_bus, lkas_msg=MSG_SUBARU_ES_LKAS):
return [[lkas_msg, SUBARU_MAIN_BUS],
[MSG_SUBARU_ES_Distance, alt_bus],
[MSG_SUBARU_ES_DashStatus, SUBARU_MAIN_BUS],
[MSG_SUBARU_ES_LKAS_State, SUBARU_MAIN_BUS],
Expand All @@ -36,8 +37,8 @@ def long_tx_msgs():
return [[MSG_SUBARU_ES_Brake, SUBARU_MAIN_BUS],
[MSG_SUBARU_ES_Status, SUBARU_MAIN_BUS]]

def fwd_blacklisted_addr():
return {SUBARU_CAM_BUS: [MSG_SUBARU_ES_LKAS, MSG_SUBARU_ES_DashStatus, MSG_SUBARU_ES_LKAS_State, MSG_SUBARU_ES_Infotainment]}
def fwd_blacklisted_addr(lkas_msg=MSG_SUBARU_ES_LKAS):
return {SUBARU_CAM_BUS: [lkas_msg, MSG_SUBARU_ES_DashStatus, MSG_SUBARU_ES_LKAS_State, MSG_SUBARU_ES_Infotainment]}

class TestSubaruSafetyBase(common.PandaSafetyTest, MeasurementSafetyTest):
FLAGS = 0
Expand Down

0 comments on commit 04df95d

Please sign in to comment.