Skip to content

Commit

Permalink
MISRA why you gotta do me like that?
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung8607 committed Mar 17, 2023
1 parent 0e47ef9 commit ea5e153
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions board/safety/safety_volkswagen_mlb.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ static int volkswagen_mlb_rx_hook(CANPacket_t *to_push) {
// Check all wheel speeds for any movement
// Signals: ESP_03.ESP_[VL|VR|HL|HR]_Radgeschw
if (addr == MSG_ESP_03) {
int speed = 0;
speed += GET_BYTE(to_push, 2) | ((GET_BYTE(to_push, 3) & 0xFU) << 8); // FL
speed += ((GET_BYTE(to_push, 3) & 0xF0) >> 4) | (GET_BYTE(to_push, 4) << 4); // FR
speed += GET_BYTE(to_push, 5) | ((GET_BYTE(to_push, 6) & 0xFU) << 8); // RL
speed += ((GET_BYTE(to_push, 6) & 0xF0) >> 4) | (GET_BYTE(to_push, 7) << 4); // RR
vehicle_moving = speed > 0;
int wheel_speed_fl = GET_BYTE(to_push, 2) | ((GET_BYTE(to_push, 3) & 0xFU) << 8);
int wheel_speed_fr = ((GET_BYTE(to_push, 3) & 0xF0) >> 4) | (GET_BYTE(to_push, 4) << 4);
int wheel_speed_rl = GET_BYTE(to_push, 5) | ((GET_BYTE(to_push, 6) & 0xFU) << 8);
int wheel_speed_rr = ((GET_BYTE(to_push, 6) & 0xF0) >> 4) | (GET_BYTE(to_push, 7) << 4);
vehicle_moving = wheel_speed_fl + wheel_speed_fr + wheel_speed_rl + wheel_speed_rr > 0;
}

// Update driver input torque
Expand Down

0 comments on commit ea5e153

Please sign in to comment.