Keep Kona handoff compliant with native safety lint

This commit is contained in:
firestar5683
2026-11-23 23:19:22 -06:00
parent 951beb26be
commit 07331b33e8
39 changed files with 30 additions and 28 deletions
@@ -1288,18 +1288,7 @@ static bool hyundai_kona_camera_fwd(const CANPacket_t *msg) {
}
#endif
static bool hyundai_canfd_tx_hook(const CANPacket_t *msg) {
#ifdef ALLOW_DEBUG
if (hyundai_kona_idle_handoff && (msg->addr == 0x12AU)) {
const uint32_t now = microsecond_timer_get();
if (safety_rx_checks_invalid || !aol_rx_healthy() || !hyundai_kona_host_steering() ||
!hyundai_kona_lfa_valid(msg) || !hyundai_kona_camera_seen ||
(safety_get_ts_elapsed(now, hyundai_kona_camera_ts) > 50000U) ||
(msg->data[2] != hyundai_kona_camera_counter) || !hyundai_kona_output_ready(now, true, msg->data[2])) {
return false;
}
}
#endif
static bool hyundai_canfd_tx_hook_checked(const CANPacket_t *msg) {
bool tx = false;
const bool ordinary_angle_frame = hyundai_ordinary_angle_stock && ((msg->addr == 0x110U) || (msg->addr == 0x362U));
bool ordinary_angle_valid = true;
@@ -1367,6 +1356,24 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *msg) {
return tx;
}
static bool hyundai_canfd_tx_hook(const CANPacket_t *msg) {
#ifdef ALLOW_DEBUG
bool allowed = true;
if (hyundai_kona_idle_handoff && (msg->addr == 0x12AU)) {
const uint32_t now = microsecond_timer_get();
allowed = !safety_rx_checks_invalid && aol_rx_healthy() && hyundai_kona_host_steering() &&
hyundai_kona_lfa_valid(msg) && hyundai_kona_camera_seen &&
(safety_get_ts_elapsed(now, hyundai_kona_camera_ts) <= 50000U) &&
(msg->data[2] == hyundai_kona_camera_counter) && hyundai_kona_output_ready(now, true, msg->data[2]);
}
#endif
return
#ifdef ALLOW_DEBUG
allowed &&
#endif
hyundai_canfd_tx_hook_checked(msg);
}
static void hyundai_canfd_reset_ioniq6_state(void) {
hyundai_canfd_ioniq6_long = false;
aol_ioniq6_long = false;
@@ -2314,37 +2321,32 @@ static safety_config hyundai_canfd_init_validated(uint16_t supplied_param) {
return ret;
}
static safety_config hyundai_canfd_init(uint16_t param) {
static safety_config hyundai_canfd_init(uint16_t raw_param) {
hyundai_daw_init(true, false);
hyundai_canfd_reset_ioniq6_state();
hyundai_ordinary_angle_reset();
#ifdef ALLOW_DEBUG
hyundai_kona_idle_handoff = (param == 0x1C0CU) && (alternative_experience == 32);
hyundai_kona_idle_handoff = (raw_param == 0x1C0CU) && (alternative_experience == 32);
hyundai_kona_camera_seen = false;
hyundai_kona_output_seen = false;
if ((param == 0x1C0CU) && !hyundai_kona_idle_handoff) {
return (safety_config){.disable_forwarding = true};
}
if (hyundai_kona_idle_handoff) {
param = 0x0C0CU;
}
const bool kona_profile_valid = (raw_param != 0x1C0CU) || hyundai_kona_idle_handoff;
const uint16_t param = hyundai_kona_idle_handoff ? 0x0C0CU : raw_param;
const bool valid = !GET_FLAG(param, 32768U) || (param == 0x8015U) || (param == 0x8095U) ||
(param == 0x8815U) || (param == 0x8895U) ||
hyundai_canfd_gv60_long_param(param);
#else
if (param == 0x1C0CU) {
return (safety_config){.disable_forwarding = true};
}
const bool kona_profile_valid = raw_param != 0x1C0CU;
const uint16_t param = raw_param;
const bool valid = !GET_FLAG(param, 32768U);
#endif
safety_config ret = {0};
safety_config ret = {.disable_forwarding = !kona_profile_valid};
const bool marker_valid = GET_FLAG(param, 16384U) || !GET_FLAG(param, 2048U) ||
hyundai_canfd_stock_torque_aol_param(param) ||
#ifdef ALLOW_DEBUG
(hyundai_canfd_torque_long_aol_param(param) && ((unsigned int)alternative_experience == 32U)) ||
#endif
(param == 0x8815U) || (param == 0x8895U);
if (valid && marker_valid) {
if (kona_profile_valid && valid && marker_valid) {
ret = hyundai_canfd_init_validated(param);
const bool daw_profile = (param == 0x0011U) || (param == 0x0091U) || (param == 0x0811U) || (param == 0x0891U) ||
(param == 0x8015U) || (param == 0x8095U) || (param == 0x8815U) || (param == 0x8895U);
@@ -2355,7 +2357,7 @@ static safety_config hyundai_canfd_init(uint16_t param) {
if (hyundai_canfd_angle_aol_capacity(&ret)) {
for (int i = 0; i < ret.tx_msgs_len; i++) {
kona_tx[i] = ret.tx_msgs[i];
if (kona_tx[i].addr == 0x12AU) {
if (kona_tx[i].addr == 0x12A) {
kona_tx[i].disable_static_blocking = true;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
DEV-82f431d8-Pf38f504f-DEBUG
DEV-7950d25a-Pf38f504f-DEBUG
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "00bca4db20a71c78165d81ae1a3b8d82fa5cdf7ffb76ae2083dce98e954bc57d", "schema_version": 1}
{"protected_inventory_sha256": "51265765f641a458e3d3b52679dc3b8e372fc6b72ebf5012f1e2d2f1e7e28f5c", "schema_version": 1}