Skip to content

Commit

Permalink
common addrs behind macros
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Sep 7, 2023
1 parent cb0cd1b commit 51a254f
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,38 @@ const CanMsg HYUNDAI_CAMERA_SCC_TX_MSGS[] = {
{0x485, 0, 4}, // LFAHDA_MFC Bus 0
};

#define HYUNDAI_COMMON_ADDR_CHECKS(legacy) \
{.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U}, \
{0x371, 0, 8, .expected_timestep = 10000U}, { 0 }}}, \
{.msg = {{0x386, 0, 8, .check_checksum = !legacy, .max_counter = legacy ? 0U : 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, \
{.msg = {{0x394, 0, 8, .check_checksum = !legacy, .max_counter = legacy ? 0U : 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}}, \

#define HYUNDAI_SCC12_ADDR_CHECK(scc_bus) \
{.msg = {{0x421, scc_bus, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}}, \

AddrCheckStruct hyundai_addr_checks[] = {
{.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{0x371, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{0x386, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x394, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x421, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
HYUNDAI_COMMON_ADDR_CHECKS(false)
HYUNDAI_SCC12_ADDR_CHECK(0)
};
#define HYUNDAI_ADDR_CHECK_LEN (sizeof(hyundai_addr_checks) / sizeof(hyundai_addr_checks[0]))

AddrCheckStruct hyundai_cam_scc_addr_checks[] = {
{.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{0x371, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{0x386, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x394, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x421, 2, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
HYUNDAI_COMMON_ADDR_CHECKS(false)
HYUNDAI_SCC12_ADDR_CHECK(2)
};
#define HYUNDAI_CAM_SCC_ADDR_CHECK_LEN (sizeof(hyundai_cam_scc_addr_checks) / sizeof(hyundai_cam_scc_addr_checks[0]))

AddrCheckStruct hyundai_long_addr_checks[] = {
{.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{0x371, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{0x386, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x394, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
HYUNDAI_COMMON_ADDR_CHECKS(false)
// Use CLU11 (buttons) to manage controls allowed instead of SCC cruise state
{.msg = {{0x4F1, 0, 4, .check_checksum = false, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
};
#define HYUNDAI_LONG_ADDR_CHECK_LEN (sizeof(hyundai_long_addr_checks) / sizeof(hyundai_long_addr_checks[0]))

// older hyundai models have less checks due to missing counters and checksums
AddrCheckStruct hyundai_legacy_addr_checks[] = {
{.msg = {{0x260, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{0x371, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{0x386, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x394, 0, 8, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{0x421, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
HYUNDAI_COMMON_ADDR_CHECKS(true)
HYUNDAI_SCC12_ADDR_CHECK(0)
};
#define HYUNDAI_LEGACY_ADDR_CHECK_LEN (sizeof(hyundai_legacy_addr_checks) / sizeof(hyundai_legacy_addr_checks[0]))

Expand Down

0 comments on commit 51a254f

Please sign in to comment.