Skip to content

Commit

Permalink
GM: simplified max steer check logic, Cadillac: fixed can parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
rbiasini committed Jun 2, 2018
1 parent c7e2c2d commit 8fa507b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion board/safety/safety_cadillac.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void cadillac_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
uint32_t addr = to_push->RIR >> 21;

if (addr == 356) {
int torque_driver_new = ((to_push->RDLR & 0x3) << 8) | ((to_push->RDLR >> 8) & 0xFF);
int torque_driver_new = ((to_push->RDLR & 0x7) << 8) | ((to_push->RDLR >> 8) & 0xFF);
torque_driver_new = to_signed(torque_driver_new, 11);

// update array of sample
Expand Down
8 changes: 2 additions & 6 deletions board/safety/safety_gm.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,10 @@ static int gm_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
if (addr == 384) {
int rdlr = to_send->RDLR;
int steer = ((rdlr & 0x7) << 8) + ((rdlr & 0xFF00) >> 8);
steer = to_signed(steer, 11);
int max_steer = 255;
if (current_controls_allowed) {
// Signed arithmetic
if (steer & 0x400) {
if (steer < (0x800 - max_steer)) return 0;
} else {
if (steer > max_steer) return 0;
}
if ((steer > max_steer) || (steer < -max_steer)) return 0;
} else {
if (steer != 0) return 0;
}
Expand Down

0 comments on commit 8fa507b

Please sign in to comment.