Skip to content

Commit

Permalink
Hyundai: fix addr check race condition (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Oct 3, 2022
1 parent 1910db8 commit 4248085
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ AddrCheckStruct hyundai_addr_checks[] = {
{881, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{902, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U},
{1057, 2, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }}},
{.msg = {{1057, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
};
#define HYUNDAI_ADDR_CHECK_LEN (sizeof(hyundai_addr_checks) / sizeof(hyundai_addr_checks[0]))

AddrCheckStruct hyundai_cam_scc_addr_checks[] = {
{.msg = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{881, 0, 8, .expected_timestep = 10000U}, { 0 }}},
{.msg = {{902, 0, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{916, 0, 8, .check_checksum = true, .max_counter = 7U, .expected_timestep = 10000U}, { 0 }, { 0 }}},
{.msg = {{1057, 2, 8, .check_checksum = true, .max_counter = 15U, .expected_timestep = 20000U}, { 0 }, { 0 }}},
};
#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 = {{608, 0, 8, .check_checksum = true, .max_counter = 3U, .expected_timestep = 10000U},
{881, 0, 8, .expected_timestep = 10000U}, { 0 }}},
Expand Down Expand Up @@ -373,6 +381,8 @@ static const addr_checks* hyundai_init(uint16_t param) {

if (hyundai_longitudinal) {
hyundai_rx_checks = (addr_checks){hyundai_long_addr_checks, HYUNDAI_LONG_ADDR_CHECK_LEN};
} else if (hyundai_camera_scc) {
hyundai_rx_checks = (addr_checks){hyundai_cam_scc_addr_checks, HYUNDAI_CAM_SCC_ADDR_CHECK_LEN};
} else {
hyundai_rx_checks = (addr_checks){hyundai_addr_checks, HYUNDAI_ADDR_CHECK_LEN};
}
Expand Down

0 comments on commit 4248085

Please sign in to comment.