Skip to content

Commit

Permalink
diff reduction: won't need the flag rename
Browse files Browse the repository at this point in the history
  • Loading branch information
jyoung8607 committed Oct 1, 2024
1 parent 473dde0 commit bee8371
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions board/safety/safety_toyota.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
{0x224, 0, 8, .check_checksum = false, .frequency = 40U}, \
{0x226, 0, 8, .check_checksum = false, .frequency = 40U}}}, \

static bool toyota_alt_brake_224 = false;
static bool toyota_alt_brake = false;
static bool toyota_alt_brake_101 = false;
static bool toyota_alt_pcm_cruise_176 = false;
static bool toyota_alt_gas_pedal_116 = false;
Expand Down Expand Up @@ -124,13 +124,13 @@ static void toyota_rx_hook(const CANPacket_t *to_push) {
}

// most cars have brake_pressed on 0x226, corolla and rav4 on 0x224, rav4 prime on 0x101
if (toyota_alt_brake_224 && !toyota_alt_brake_101 && (addr == 0x224)) {
if (toyota_alt_brake && !toyota_alt_brake_101 && (addr == 0x224)) {
brake_pressed = GET_BIT(to_push, 5U);
}
if (!toyota_alt_brake_224 && toyota_alt_brake_101 && (addr == 0x101)) {
if (!toyota_alt_brake && toyota_alt_brake_101 && (addr == 0x101)) {
brake_pressed = GET_BIT(to_push, 3U);
}
if (!toyota_alt_brake_224 && !toyota_alt_brake_101 && (addr == 0x226)) {
if (!toyota_alt_brake && !toyota_alt_brake_101 && (addr == 0x226)) {
brake_pressed = GET_BIT(to_push, 37U);
}

Expand Down Expand Up @@ -319,12 +319,12 @@ static safety_config toyota_init(uint16_t param) {
// first byte is for EPS factor, second is for flags
const uint32_t TOYOTA_PARAM_OFFSET = 8U;
const uint32_t TOYOTA_EPS_FACTOR = (1UL << TOYOTA_PARAM_OFFSET) - 1U;
const uint32_t TOYOTA_PARAM_ALT_BRAKE_224 = 1UL << TOYOTA_PARAM_OFFSET;
const uint32_t TOYOTA_PARAM_ALT_BRAKE = 1UL << TOYOTA_PARAM_OFFSET;
const uint32_t TOYOTA_PARAM_STOCK_LONGITUDINAL = 2UL << TOYOTA_PARAM_OFFSET;
const uint32_t TOYOTA_PARAM_LTA = 4UL << TOYOTA_PARAM_OFFSET;
const uint32_t TOYOTA_PARAM_SECOC_CAR = 8UL << TOYOTA_PARAM_OFFSET;

toyota_alt_brake_224 = GET_FLAG(param, TOYOTA_PARAM_ALT_BRAKE_224);
toyota_alt_brake = GET_FLAG(param, TOYOTA_PARAM_ALT_BRAKE);
toyota_stock_longitudinal = GET_FLAG(param, TOYOTA_PARAM_STOCK_LONGITUDINAL);

bool secoc_car = GET_FLAG(param, TOYOTA_PARAM_SECOC_CAR);
Expand Down
2 changes: 1 addition & 1 deletion python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class Panda:
HARNESS_STATUS_FLIPPED = 2

# first byte is for EPS scaling factor
FLAG_TOYOTA_ALT_BRAKE_224 = (1 << 8)
FLAG_TOYOTA_ALT_BRAKE = (1 << 8)
FLAG_TOYOTA_STOCK_LONGITUDINAL = (2 << 8)
FLAG_TOYOTA_LTA = (4 << 8)
FLAG_TOYOTA_SECOC_CAR = (8 << 8)
Expand Down
2 changes: 1 addition & 1 deletion tests/safety/test_toyota.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class TestToyotaAltBrakeSafety(TestToyotaSafetyTorque):
def setUp(self):
self.packer = CANPackerPanda("toyota_new_mc_pt_generated")
self.safety = libpanda_py.libpanda
self.safety.set_safety_hooks(Panda.SAFETY_TOYOTA, self.EPS_SCALE | Panda.FLAG_TOYOTA_ALT_BRAKE_224)
self.safety.set_safety_hooks(Panda.SAFETY_TOYOTA, self.EPS_SCALE | Panda.FLAG_TOYOTA_ALT_BRAKE)
self.safety.init_tests()

def _user_brake_msg(self, brake):
Expand Down

0 comments on commit bee8371

Please sign in to comment.