diff --git a/board/safety/safety_body.h b/board/safety/safety_body.h index 61232a3bd..c239e245b 100644 --- a/board/safety/safety_body.h +++ b/board/safety/safety_body.h @@ -16,18 +16,18 @@ static void body_rx_hook(CANPacket_t *to_push) { } static bool body_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); int len = GET_LEN(to_send); if (!controls_allowed && (addr != 0x1)) { - tx = 0; + tx = false; } // Allow going into CAN flashing mode for base & knee even if controls are not allowed bool flash_msg = ((addr == 0x250) || (addr == 0x350)) && (len == 8); if (!controls_allowed && (GET_BYTES(to_send, 0, 4) == 0xdeadfaceU) && (GET_BYTES(to_send, 4, 4) == 0x0ab00b1eU) && flash_msg) { - tx = 1; + tx = true; } return tx; diff --git a/board/safety/safety_chrysler.h b/board/safety/safety_chrysler.h index 13ee47368..d26181227 100644 --- a/board/safety/safety_chrysler.h +++ b/board/safety/safety_chrysler.h @@ -214,7 +214,7 @@ static void chrysler_rx_hook(CANPacket_t *to_push) { } static bool chrysler_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); // STEERING @@ -228,7 +228,7 @@ static bool chrysler_tx_hook(CANPacket_t *to_send) { bool steer_req = (chrysler_platform == CHRYSLER_PACIFICA) ? (GET_BIT(to_send, 4U) != 0U) : ((GET_BYTE(to_send, 3) & 0x7U) == 2U); if (steer_torque_cmd_checks(desired_torque, steer_req, limits)) { - tx = 0; + tx = false; } } @@ -238,7 +238,7 @@ static bool chrysler_tx_hook(CANPacket_t *to_send) { const bool is_resume = GET_BYTE(to_send, 0) == 0x10U; const bool allowed = is_cancel || (is_resume && controls_allowed); if (!allowed) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_elm327.h b/board/safety/safety_elm327.h index 0d520b17b..84433239f 100644 --- a/board/safety/safety_elm327.h +++ b/board/safety/safety_elm327.h @@ -1,18 +1,18 @@ static bool elm327_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); int len = GET_LEN(to_send); // All ISO 15765-4 messages must be 8 bytes long if (len != 8) { - tx = 0; + tx = false; } // Check valid 29 bit send addresses for ISO 15765-4 // Check valid 11 bit send addresses for ISO 15765-4 if ((addr != 0x18DB33F1) && ((addr & 0x1FFF00FF) != 0x18DA00F1) && ((addr & 0x1FFFFF00) != 0x600) && ((addr & 0x1FFFFF00) != 0x700)) { - tx = 0; + tx = false; } return tx; } diff --git a/board/safety/safety_ford.h b/board/safety/safety_ford.h index d7b157c48..4c8e2abf1 100644 --- a/board/safety/safety_ford.h +++ b/board/safety/safety_ford.h @@ -286,7 +286,7 @@ static bool ford_tx_hook(CANPacket_t *to_send) { violation |= cmbb_deny != 0; // do not prevent stock AEB actuation if (violation) { - tx = 0; + tx = false; } } @@ -301,7 +301,7 @@ static bool ford_tx_hook(CANPacket_t *to_send) { violation |= (GET_BIT(to_send, 25U) == 1U) && !controls_allowed; // Signal: CcAsllButtnResPress (resume) if (violation) { - tx = 0; + tx = false; } } @@ -313,7 +313,7 @@ static bool ford_tx_hook(CANPacket_t *to_send) { // but the action (LkaActvStats_D2_Req) must be set to zero. unsigned int action = GET_BYTE(to_send, 0) >> 5; if (action != 0U) { - tx = 0; + tx = false; } } @@ -334,7 +334,7 @@ static bool ford_tx_hook(CANPacket_t *to_send) { violation |= steer_angle_cmd_checks(desired_curvature, steer_control_enabled, FORD_STEERING_LIMITS); if (violation) { - tx = 0; + tx = false; } } @@ -355,7 +355,7 @@ static bool ford_tx_hook(CANPacket_t *to_send) { violation |= steer_angle_cmd_checks(desired_curvature, steer_control_enabled, FORD_STEERING_LIMITS); if (violation) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_gm.h b/board/safety/safety_gm.h index 70dc4cfff..bd8210b59 100644 --- a/board/safety/safety_gm.h +++ b/board/safety/safety_gm.h @@ -136,7 +136,7 @@ static void gm_rx_hook(CANPacket_t *to_push) { } static bool gm_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); // BRAKE: safety check @@ -144,7 +144,7 @@ static bool gm_tx_hook(CANPacket_t *to_send) { int brake = ((GET_BYTE(to_send, 0) & 0xFU) << 8) + GET_BYTE(to_send, 1); brake = (0x1000 - brake) & 0xFFF; if (longitudinal_brake_checks(brake, *gm_long_limits)) { - tx = 0; + tx = false; } } @@ -156,7 +156,7 @@ static bool gm_tx_hook(CANPacket_t *to_send) { bool steer_req = (GET_BIT(to_send, 3U) != 0U); if (steer_torque_cmd_checks(desired_torque, steer_req, GM_STEERING_LIMITS)) { - tx = 0; + tx = false; } } @@ -171,7 +171,7 @@ static bool gm_tx_hook(CANPacket_t *to_send) { violation |= longitudinal_gas_checks(gas_regen, *gm_long_limits); if (violation) { - tx = 0; + tx = false; } } @@ -181,7 +181,7 @@ static bool gm_tx_hook(CANPacket_t *to_send) { bool allowed_cancel = (button == 6) && cruise_engaged_prev; if (!allowed_cancel) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_honda.h b/board/safety/safety_honda.h index 0bc41dbb3..4ce3661b2 100644 --- a/board/safety/safety_honda.h +++ b/board/safety/safety_honda.h @@ -261,7 +261,7 @@ static void honda_rx_hook(CANPacket_t *to_push) { } static bool honda_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); @@ -277,7 +277,7 @@ static bool honda_tx_hook(CANPacket_t *to_send) { violation |= longitudinal_speed_checks(pcm_speed, HONDA_NIDEC_LONG_LIMITS); violation |= longitudinal_gas_checks(pcm_gas, HONDA_NIDEC_LONG_LIMITS); if (violation) { - tx = 0; + tx = false; } } @@ -285,10 +285,10 @@ static bool honda_tx_hook(CANPacket_t *to_send) { if ((addr == 0x1FA) && (bus == bus_pt)) { honda_brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3U); if (longitudinal_brake_checks(honda_brake, HONDA_NIDEC_LONG_LIMITS)) { - tx = 0; + tx = false; } if (honda_fwd_brake) { - tx = 0; + tx = false; } } @@ -304,7 +304,7 @@ static bool honda_tx_hook(CANPacket_t *to_send) { violation |= longitudinal_accel_checks(accel, HONDA_BOSCH_LONG_LIMITS); violation |= longitudinal_gas_checks(gas, HONDA_BOSCH_LONG_LIMITS); if (violation) { - tx = 0; + tx = false; } } @@ -316,7 +316,7 @@ static bool honda_tx_hook(CANPacket_t *to_send) { bool violation = false; violation |= longitudinal_accel_checks(accel, HONDA_BOSCH_LONG_LIMITS); if (violation) { - tx = 0; + tx = false; } } @@ -325,7 +325,7 @@ static bool honda_tx_hook(CANPacket_t *to_send) { if (!controls_allowed) { bool steer_applied = GET_BYTE(to_send, 0) | GET_BYTE(to_send, 1); if (steer_applied) { - tx = 0; + tx = false; } } } @@ -333,14 +333,14 @@ static bool honda_tx_hook(CANPacket_t *to_send) { // Bosch supplemental control check if (addr == 0xE5) { if ((GET_BYTES(to_send, 0, 4) != 0x10800004U) || ((GET_BYTES(to_send, 4, 4) & 0x00FFFFFFU) != 0x0U)) { - tx = 0; + tx = false; } } // GAS: safety check (interceptor) if (addr == 0x200) { if (longitudinal_interceptor_checks(to_send)) { - tx = 0; + tx = false; } } @@ -349,14 +349,14 @@ static bool honda_tx_hook(CANPacket_t *to_send) { // This avoids unintended engagements while still allowing resume spam if ((addr == 0x296) && !controls_allowed && (bus == bus_buttons)) { if (((GET_BYTE(to_send, 0) >> 5) & 0x7U) != 2U) { - tx = 0; + tx = false; } } // Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address if (addr == 0x18DAB0F1) { if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_hyundai.h b/board/safety/safety_hyundai.h index f196901ff..7c19ba564 100644 --- a/board/safety/safety_hyundai.h +++ b/board/safety/safety_hyundai.h @@ -215,7 +215,7 @@ static void hyundai_rx_hook(CANPacket_t *to_push) { } static bool hyundai_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); // FCA11: Block any potential actuation @@ -225,7 +225,7 @@ static bool hyundai_tx_hook(CANPacket_t *to_send) { int CF_VSM_DecCmdAct = GET_BIT(to_send, 31U); if ((CR_VSM_DecCmd != 0) || (FCA_CmdAct != 0) || (CF_VSM_DecCmdAct != 0)) { - tx = 0; + tx = false; } } @@ -245,7 +245,7 @@ static bool hyundai_tx_hook(CANPacket_t *to_send) { violation |= (aeb_req != 0); if (violation) { - tx = 0; + tx = false; } } @@ -256,14 +256,14 @@ static bool hyundai_tx_hook(CANPacket_t *to_send) { const SteeringLimits limits = hyundai_alt_limits ? HYUNDAI_STEERING_LIMITS_ALT : HYUNDAI_STEERING_LIMITS; if (steer_torque_cmd_checks(desired_torque, steer_req, limits)) { - tx = 0; + tx = false; } } // UDS: Only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address if (addr == 0x7D0) { if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) { - tx = 0; + tx = false; } } @@ -274,7 +274,7 @@ static bool hyundai_tx_hook(CANPacket_t *to_send) { bool allowed_resume = (button == 1) && controls_allowed; bool allowed_cancel = (button == 4) && cruise_engaged_prev; if (!(allowed_resume || allowed_cancel)) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_hyundai_canfd.h b/board/safety/safety_hyundai_canfd.h index 7818c8624..22dc387bf 100644 --- a/board/safety/safety_hyundai_canfd.h +++ b/board/safety/safety_hyundai_canfd.h @@ -228,7 +228,7 @@ static void hyundai_canfd_rx_hook(CANPacket_t *to_push) { } static bool hyundai_canfd_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); // steering @@ -238,7 +238,7 @@ static bool hyundai_canfd_tx_hook(CANPacket_t *to_send) { bool steer_req = GET_BIT(to_send, 52U) != 0U; if (steer_torque_cmd_checks(desired_torque, steer_req, HYUNDAI_CANFD_STEERING_LIMITS)) { - tx = 0; + tx = false; } } @@ -250,14 +250,14 @@ static bool hyundai_canfd_tx_hook(CANPacket_t *to_send) { bool allowed = (is_cancel && cruise_engaged_prev) || (is_resume && controls_allowed); if (!allowed) { - tx = 0; + tx = false; } } // UDS: only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address if ((addr == 0x730) && hyundai_canfd_hda2) { if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) { - tx = 0; + tx = false; } } @@ -279,7 +279,7 @@ static bool hyundai_canfd_tx_hook(CANPacket_t *to_send) { } if (violation) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_mazda.h b/board/safety/safety_mazda.h index 82da5b0a3..83e760628 100644 --- a/board/safety/safety_mazda.h +++ b/board/safety/safety_mazda.h @@ -69,7 +69,7 @@ static void mazda_rx_hook(CANPacket_t *to_push) { } static bool mazda_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); @@ -81,7 +81,7 @@ static bool mazda_tx_hook(CANPacket_t *to_send) { int desired_torque = (((GET_BYTE(to_send, 0) & 0x0FU) << 8) | GET_BYTE(to_send, 1)) - 2048U; if (steer_torque_cmd_checks(desired_torque, -1, MAZDA_STEERING_LIMITS)) { - tx = 0; + tx = false; } } @@ -91,7 +91,7 @@ static bool mazda_tx_hook(CANPacket_t *to_send) { // only allow cancel while contrls not allowed bool cancel_cmd = (GET_BYTE(to_send, 0) == 0x1U); if (!controls_allowed && !cancel_cmd) { - tx = 0; + tx = false; } } } diff --git a/board/safety/safety_nissan.h b/board/safety/safety_nissan.h index cb7bb9e06..82608d852 100644 --- a/board/safety/safety_nissan.h +++ b/board/safety/safety_nissan.h @@ -94,7 +94,7 @@ static void nissan_rx_hook(CANPacket_t *to_push) { static bool nissan_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); bool violation = false; @@ -118,7 +118,7 @@ static bool nissan_tx_hook(CANPacket_t *to_send) { } if (violation) { - tx = 0; + tx = false; } return tx; diff --git a/board/safety/safety_subaru.h b/board/safety/safety_subaru.h index 1c762d55f..b70180c9b 100644 --- a/board/safety/safety_subaru.h +++ b/board/safety/safety_subaru.h @@ -181,7 +181,7 @@ static void subaru_rx_hook(CANPacket_t *to_push) { } static bool subaru_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); bool violation = false; @@ -234,7 +234,7 @@ static bool subaru_tx_hook(CANPacket_t *to_send) { } if (violation){ - tx = 0; + tx = false; } return tx; } diff --git a/board/safety/safety_subaru_preglobal.h b/board/safety/safety_subaru_preglobal.h index b246f4120..03334e5dd 100644 --- a/board/safety/safety_subaru_preglobal.h +++ b/board/safety/safety_subaru_preglobal.h @@ -78,7 +78,7 @@ static void subaru_preglobal_rx_hook(CANPacket_t *to_push) { } static bool subaru_preglobal_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); // steer cmd checks @@ -89,7 +89,7 @@ static bool subaru_preglobal_tx_hook(CANPacket_t *to_send) { bool steer_req = (GET_BIT(to_send, 24U) != 0U); if (steer_torque_cmd_checks(desired_torque, steer_req, SUBARU_PG_STEERING_LIMITS)) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_tesla.h b/board/safety/safety_tesla.h index dbfda37b0..17969f74d 100644 --- a/board/safety/safety_tesla.h +++ b/board/safety/safety_tesla.h @@ -117,7 +117,7 @@ static void tesla_rx_hook(CANPacket_t *to_push) { static bool tesla_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); bool violation = false; @@ -168,7 +168,7 @@ static bool tesla_tx_hook(CANPacket_t *to_send) { } if (violation) { - tx = 0; + tx = false; } return tx; diff --git a/board/safety/safety_toyota.h b/board/safety/safety_toyota.h index 60853c023..752f16708 100644 --- a/board/safety/safety_toyota.h +++ b/board/safety/safety_toyota.h @@ -140,7 +140,7 @@ static void toyota_rx_hook(CANPacket_t *to_push) { } static bool toyota_tx_hook(CANPacket_t *to_send) { - int tx = 1; + bool tx = true; int addr = GET_ADDR(to_send); int bus = GET_BUS(to_send); @@ -150,7 +150,7 @@ static bool toyota_tx_hook(CANPacket_t *to_send) { // GAS PEDAL: safety check if (addr == 0x200) { if (longitudinal_interceptor_checks(to_send)) { - tx = 0; + tx = false; } } @@ -174,7 +174,7 @@ static bool toyota_tx_hook(CANPacket_t *to_send) { } if (violation) { - tx = 0; + tx = false; } } @@ -183,7 +183,7 @@ static bool toyota_tx_hook(CANPacket_t *to_send) { // only allow the checksum, which is the last byte bool block = (GET_BYTES(to_send, 0, 4) != 0U) || (GET_BYTE(to_send, 4) != 0U) || (GET_BYTE(to_send, 5) != 0U); if (block) { - tx = 0; + tx = false; } } @@ -199,7 +199,7 @@ static bool toyota_tx_hook(CANPacket_t *to_send) { // block LTA msgs with actuation requests if (lta_request || lta_request2 || (lta_angle != 0) || (setme_x64 != 0)) { - tx = 0; + tx = false; } } @@ -209,11 +209,11 @@ static bool toyota_tx_hook(CANPacket_t *to_send) { desired_torque = to_signed(desired_torque, 16); bool steer_req = GET_BIT(to_send, 0U) != 0U; if (steer_torque_cmd_checks(desired_torque, steer_req, TOYOTA_STEERING_LIMITS)) { - tx = 0; + tx = false; } // When using LTA (angle control), assert no actuation on LKA message if (toyota_lta && ((desired_torque != 0) || steer_req)) { - tx = 0; + tx = false; } } } diff --git a/board/safety/safety_volkswagen_mqb.h b/board/safety/safety_volkswagen_mqb.h index 6b1d6d2b4..1921e138e 100644 --- a/board/safety/safety_volkswagen_mqb.h +++ b/board/safety/safety_volkswagen_mqb.h @@ -194,7 +194,7 @@ static void volkswagen_mqb_rx_hook(CANPacket_t *to_push) { static bool volkswagen_mqb_tx_hook(CANPacket_t *to_send) { int addr = GET_ADDR(to_send); - int tx = 1; + bool tx = true; // Safety check for HCA_01 Heading Control Assist torque // Signal: HCA_01.HCA_01_LM_Offset (absolute torque) @@ -209,7 +209,7 @@ static bool volkswagen_mqb_tx_hook(CANPacket_t *to_send) { bool steer_req = GET_BIT(to_send, 30U) != 0U; if (steer_torque_cmd_checks(desired_torque, steer_req, VOLKSWAGEN_MQB_STEERING_LIMITS)) { - tx = 0; + tx = false; } } @@ -233,7 +233,7 @@ static bool volkswagen_mqb_tx_hook(CANPacket_t *to_send) { violation |= longitudinal_accel_checks(desired_accel, VOLKSWAGEN_MQB_LONG_LIMITS); if (violation) { - tx = 0; + tx = false; } } @@ -242,7 +242,7 @@ static bool volkswagen_mqb_tx_hook(CANPacket_t *to_send) { if ((addr == MSG_GRA_ACC_01) && !controls_allowed) { // disallow resume and set: bits 16 and 19 if ((GET_BYTE(to_send, 2) & 0x9U) != 0U) { - tx = 0; + tx = false; } } diff --git a/board/safety/safety_volkswagen_pq.h b/board/safety/safety_volkswagen_pq.h index 509db4e77..459d1f70d 100644 --- a/board/safety/safety_volkswagen_pq.h +++ b/board/safety/safety_volkswagen_pq.h @@ -171,7 +171,7 @@ static void volkswagen_pq_rx_hook(CANPacket_t *to_push) { static bool volkswagen_pq_tx_hook(CANPacket_t *to_send) { int addr = GET_ADDR(to_send); - int tx = 1; + bool tx = true; // Safety check for HCA_1 Heading Control Assist torque // Signal: HCA_1.LM_Offset (absolute torque) @@ -188,7 +188,7 @@ static bool volkswagen_pq_tx_hook(CANPacket_t *to_send) { bool steer_req = (hca_status == 5U); if (steer_torque_cmd_checks(desired_torque, steer_req, VOLKSWAGEN_PQ_STEERING_LIMITS)) { - tx = 0; + tx = false; } } @@ -199,7 +199,7 @@ static bool volkswagen_pq_tx_hook(CANPacket_t *to_send) { int desired_accel = ((((GET_BYTE(to_send, 4) & 0x7U) << 8) | GET_BYTE(to_send, 3)) * 5U) - 7220U; if (longitudinal_accel_checks(desired_accel, VOLKSWAGEN_PQ_LONG_LIMITS)) { - tx = 0; + tx = false; } } @@ -209,7 +209,7 @@ static bool volkswagen_pq_tx_hook(CANPacket_t *to_send) { // Signal: GRA_Neu.GRA_Neu_Setzen // Signal: GRA_Neu.GRA_Neu_Recall if (GET_BIT(to_send, 16U) || GET_BIT(to_send, 17U)) { - tx = 0; + tx = false; } }