Skip to content

Commit

Permalink
draft so far
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Sep 7, 2023
1 parent 51a254f commit e41b796
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 4 additions & 1 deletion board/safety.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,11 @@ bool addr_safety_check(CANPacket_t *to_push,
} else {
rx_checks->check[index].valid_quality_flag = true;
}
return is_msg_valid(rx_checks->check, index);
} else {
// return invalid to safety modes for messages not in checks
return false;
}
return is_msg_valid(rx_checks->check, index);
}

void generic_rx_checks(bool stock_ecu_detected) {
Expand Down
2 changes: 1 addition & 1 deletion board/safety/safety_hyundai.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ static int hyundai_rx_hook(CANPacket_t *to_push) {
}
generic_rx_checks(stock_ecu_detected);
}
return valid;
return true;
}

static int hyundai_tx_hook(CANPacket_t *to_send) {
Expand Down
14 changes: 13 additions & 1 deletion board/safety/safety_hyundai_canfd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = {
{0x1E0, 0, 16}, // LFAHDA_CLUSTER
};

#define HYUNDAI_CANFD_EV_ADDR_CHECKS \
/* ACCELERATOR: buses are swapped for HDA2 variants */ \
{.msg = {{0x35, 1, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, \
{0x35, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, { 0 }}}, \
/* TCS buses are swapped for HDA2 variants */ \
{.msg = {{0x175, 1, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, \
{0x175, 0, 24, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 20000U}, { 0 }}}, \

#define HYUNDAI_CANFD_HYBRID_ADDR_CHECKS \
/* ACCELERATOR_ALT: TODO: bus is always PT? no HDA hybrids? */ \
{.msg = {{0x105, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U}, { 0 }, { 0 }}}, \

AddrCheckStruct hyundai_canfd_addr_checks[] = {
{.msg = {{0x35, 1, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U},
{0x35, 0, 32, .check_checksum = true, .max_counter = 0xffU, .expected_timestep = 10000U},
Expand Down Expand Up @@ -253,7 +265,7 @@ static int hyundai_canfd_rx_hook(CANPacket_t *to_push) {
}
generic_rx_checks(stock_ecu_detected);

return valid;
return true;
}

static int hyundai_canfd_tx_hook(CANPacket_t *to_send) {
Expand Down

0 comments on commit e41b796

Please sign in to comment.