From 732980df67e33637b5751cdec3efc5f863e57ae3 Mon Sep 17 00:00:00 2001 From: dzid26 Date: Tue, 20 Aug 2024 10:24:02 +0100 Subject: [PATCH] clean address --- board/safety/safety_bmw.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/board/safety/safety_bmw.h b/board/safety/safety_bmw.h index c66a07a931..5b6662f2ff 100644 --- a/board/safety/safety_bmw.h +++ b/board/safety/safety_bmw.h @@ -20,18 +20,18 @@ RxCheck bmw_rx_checks[] = { // todo add .check_checksum and .max_counter {.msg = {{BMW_SteeringWheelAngle, BMW_PT_CAN, 7, .frequency = 100U}, { 0 }, { 0 }}}, {.msg = {{BMW_TransmissionDataDisplay, BMW_PT_CAN, 6, .frequency = 5U}, { 0 }, { 0 }}}, // todo cruise control type dependant, use param: - // {.msg = {{BMW_CruiseControlStatus, BMW_PT_CAN, 8, .frequency = 50U}, { 0 }, { 0 }}}, - // {.msg = {{BMW_DynamicCruiseControlStatus, BMW_F_CAN, 7, .frequency = 100U}, { 0 }, { 0 }}}, - // {.msg = {{559, BMW_F_CAN, 8, .frequency = 100U}, { 0 }, { 0 }}}, - // {.msg = {{559, BMW_AUX_CAN, 8, .frequency = 100U}, { 0 }, { 0 }}}, + // {.msg = {{BMW_CruiseControlStatus, BMW_PT_CAN, 8, .frequency = 5U}, { 0 }, { 0 }}}, + // {.msg = {{BMW_DynamicCruiseControlStatus, BMW_F_CAN, 7, .frequency = 5U}, { 0 }, { 0 }}}, + // {.msg = {{0x22f, BMW_F_CAN, 8, .frequency = 100U}, { 0 }, { 0 }}}, + // {.msg = {{0x22f, BMW_AUX_CAN, 8, .frequency = 100U}, { 0 }, { 0 }}}, }; const CanMsg BMW_TX_MSGS[] = { {BMW_CruiseControlStalk, BMW_PT_CAN, 4}, // Normal cruise control send status on PT-CAN {BMW_CruiseControlStalk, BMW_F_CAN, 4}, // Dynamic cruise control send status on F-CAN - {558, BMW_F_CAN, 5}, // STEPPER_SERVO_CAN is allowed on F-CAN network - {558, BMW_AUX_CAN, 5}, // or an standalone network + {0x22e, BMW_F_CAN, 5}, // STEPPER_SERVO_CAN is allowed on F-CAN network + {0x22e, BMW_AUX_CAN, 5}, // or an standalone network }; #define KPH_TO_MS 0.277778 @@ -103,9 +103,8 @@ static void bmw_rx_hook(const CANPacket_t *to_push) { } } if (addr == BMW_TransmissionDataDisplay) { - if ((GET_BYTE(to_push, 0) & 0xF) == ((GET_BYTE(to_push, 0) >> 4) ^ 0xF)) { //check agains shift lever compliment signal - lever_position = GET_BYTE(to_push, 0) & 0xF; //compliment match - } else { + lever_position = GET_BYTE(to_push, 0) & 0xF; + if (lever_position != ((GET_BYTE(to_push, 0) >> 4) ^ 0xF)) { //check against shift lever compliment signal lever_position = -1; //invalid } // if not in Drive @@ -124,7 +123,7 @@ static void bmw_rx_hook(const CANPacket_t *to_push) { } // STEPPER_SERVO_CAN: get STEERING_STATUS - if ((addr == 559) && ((bus == BMW_F_CAN) || (bus == BMW_AUX_CAN))) { + if ((addr == 0x22f) && ((bus == BMW_F_CAN) || (bus == BMW_AUX_CAN))) { actuator_torque = ((float)(int8_t)(GET_BYTE(to_push, 2))) * CAN_ACTUATOR_TQ_FAC; //Nm if((((GET_BYTE(to_push, 1)>>4)>>CAN_ACTUATOR_CONTROL_STATUS_SOFTOFF_BIT) & 0x1) != 0x0){ //Soft off status means motor is shutting down due to error @@ -145,7 +144,6 @@ static void bmw_rx_hook(const CANPacket_t *to_push) { print("Too big angle \n"); } } - if (bmw_fmax_limit_check((bmw_rt_angle_last >= 0.) ? angle_rate : -angle_rate, angle_rate_up, -angle_rate_down)) { //should be sensitive for jerks to the outside controls_allowed = false; // todo ^ handle zero crossing a bit smarter if (cruise_engaged){ @@ -188,7 +186,7 @@ static bool bmw_tx_hook(const CANPacket_t *to_send) { // static float bmw_desired_angle_last = 0; // last desired steer angle // // STEPPER_SERVO_CAN: get STEERING_COMMAND // // do not transmit CAN message if steering angle too high - // if (addr == 558) { + // if (addr == 0x22e) { // if (((GET_BYTE(to_send, 1) >> 4) & 0b11u) != 0x0){ //control enabled // float steer_torque = ((float)(int8_t)(GET_BYTE(to_send, 4))) * CAN_ACTUATOR_TQ_FAC; //Nm // if (bmw_fmax_limit_check(steer_torque - actuator_torque, max_tq_rate, -max_tq_rate)){