Skip to content

Commit 67d5208

Browse files
committed
fix signedness issue in toyota safety
1 parent fe15d3f commit 67d5208

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.0.8
1+
v1.0.9

board/safety/safety_toyota.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ uint32_t ts_last = 0;
3232
static void toyota_rx_hook(CAN_FIFOMailBox_TypeDef *to_push) {
3333
// get eps motor torque (0.66 factor in dbc)
3434
if ((to_push->RIR>>21) == 0x260) {
35-
int torque_meas_new = (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF));
35+
int16_t torque_meas_new_16 = (((to_push->RDHR) & 0xFF00) | ((to_push->RDHR >> 16) & 0xFF));
3636

3737
// increase torque_meas by 1 to be conservative on rounding
38-
torque_meas_new = (torque_meas_new * dbc_eps_torque_factor / 100) + (torque_meas_new > 0 ? 1 : -1);
38+
int torque_meas_new = ((int)(torque_meas_new_16) * dbc_eps_torque_factor / 100) + (torque_meas_new_16 > 0 ? 1 : -1);
3939

4040
// shift the array
4141
for (int i = sizeof(torque_meas)/sizeof(torque_meas[0]) - 1; i > 0; i--) {

0 commit comments

Comments
 (0)