From 7d062147d3c4aaccc13a4c37d4b981978591a7d4 Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Mon, 2 Nov 2026 22:38:34 +0000 Subject: [PATCH] Complete native safety type checks --- opendbc_repo/opendbc/safety/modes/hyundai_canfd.h | 2 +- opendbc_repo/opendbc/safety/modes/tesla.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h index fb12bf6ad0..9b591d17fa 100644 --- a/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h +++ b/opendbc_repo/opendbc/safety/modes/hyundai_canfd.h @@ -182,7 +182,6 @@ static bool hyundai_canfd_carnival_alt_resume = false; static bool hyundai_canfd_carnival_source_valid = false; static bool hyundai_canfd_carnival_previous_valid = false; static bool hyundai_canfd_carnival_counter_seen = false; -static uint8_t hyundai_canfd_carnival_rx_counter = 0U; static bool hyundai_canfd_carnival_counter_consumed = false; static bool hyundai_canfd_angle_steering = false; static bool hyundai_canfd_angle_observed_adas = false; @@ -701,6 +700,7 @@ static void hyundai_canfd_rx_hook(const CANPacket_t *msg) { } } if (hyundai_canfd_carnival_alt_resume && (msg_matches(msg, 0x1aaU, pt_bus))) { + static uint8_t hyundai_canfd_carnival_rx_counter = 0U; const bool source_fresh = !hyundai_canfd_carnival_counter_seen || hyundai_canfd_button_counter_follows(hyundai_canfd_carnival_rx_counter, msg->data[2], 0xFFU); hyundai_canfd_carnival_counter_seen = true; diff --git a/opendbc_repo/opendbc/safety/modes/tesla.h b/opendbc_repo/opendbc/safety/modes/tesla.h index a843ac8e29..365e460973 100644 --- a/opendbc_repo/opendbc/safety/modes/tesla.h +++ b/opendbc_repo/opendbc/safety/modes/tesla.h @@ -103,7 +103,8 @@ static void tesla_rx_hook(const CANPacket_t *msg) { const int angle_meas_new = (((msg->data[4] & 0x3FU) << 8) | msg->data[5]) - 8192U; update_sample(&angle_meas, angle_meas_new); - const int torsion_bar_torque = (int)(((msg->data[2] & 0x0FU) << 8) | msg->data[3]) - 2050; + const unsigned int raw_torsion_bar_torque = ((msg->data[2] & 0x0FU) << 8) | msg->data[3]; + const int torsion_bar_torque = (int)raw_torsion_bar_torque - 2050; const int hands_on_level = msg->data[4] >> 6; // EPAS3S_handsOnLevel const int eac_status = msg->data[6] >> 5; // EPAS3S_eacStatus const int eac_error_code = msg->data[2] >> 4; // EPAS3S_eacErrorCode