Honda safety: fixed incorrect brake decoding. Due to the specific limit of 255, this change does not affect the safety behavior

master
Riccardo 2019-08-22 20:29:44 -07:00
parent 8843af7de9
commit 36067e01c7
2 changed files with 2 additions and 2 deletions

View File

@ -103,7 +103,7 @@ static int honda_tx_hook(CAN_FIFOMailBox_TypeDef *to_send) {
// BRAKE: safety check
if (addr == 0x1FA) {
int brake = (GET_BYTE(to_send, 0) << 2) + (GET_BYTE(to_send, 1) & 0x3);
int brake = (GET_BYTE(to_send, 0) << 2) + ((GET_BYTE(to_send, 1) >> 6) & 0x3);
if (!current_controls_allowed || !long_controls_allowed) {
if (brake != 0) {
tx = 0;

View File

@ -64,7 +64,7 @@ class TestHondaSafety(unittest.TestCase):
def _send_brake_msg(self, brake):
to_send = libpandasafety_py.ffi.new('CAN_FIFOMailBox_TypeDef *')
to_send[0].RIR = 0x1FA << 21
to_send[0].RDLR = ((brake & 0x3) << 8) | ((brake & 0x3FF) >> 2)
to_send[0].RDLR = ((brake & 0x3) << 14) | ((brake & 0x3FF) >> 2)
return to_send