Hyundai: fix brake pressed bitmask (#1724)

* fix

* test this
This commit is contained in:
Shane Smiskol 2023-11-17 19:58:53 -08:00 committed by GitHub
parent 7c84475410
commit 3b165ed21b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -206,7 +206,7 @@ static int hyundai_rx_hook(CANPacket_t *to_push) {
}
if (addr == 0x394) {
brake_pressed = ((GET_BYTE(to_push, 5) >> 5U) & 0x2U) == 0x2U;
brake_pressed = ((GET_BYTE(to_push, 5) >> 5U) & 0x3U) == 0x2U;
}
bool stock_ecu_detected = (addr == 0x340);

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import random
import unittest
from panda import Panda
from panda.tests.libpanda import libpanda_py
@ -85,7 +86,8 @@ class TestHyundaiSafety(HyundaiButtonBase, common.PandaCarSafetyTest, common.Dri
return self.packer.make_can_msg_panda("EMS16", 0, values, fix_checksum=checksum)
def _user_brake_msg(self, brake):
values = {"DriverOverride": 2 if brake else 0, "AliveCounterTCS": self.cnt_brake % 8}
values = {"DriverOverride": 2 if brake else random.choice((0, 1, 3)),
"AliveCounterTCS": self.cnt_brake % 8}
self.__class__.cnt_brake += 1
return self.packer.make_can_msg_panda("TCS13", 0, values, fix_checksum=checksum)