wip
This commit is contained in:
@@ -21,14 +21,12 @@ const SteeringLimits HYUNDAI_CANFD_STEERING_LIMITS = {
|
|||||||
const CanMsg HYUNDAI_CANFD_HDA2_TX_MSGS[] = {
|
const CanMsg HYUNDAI_CANFD_HDA2_TX_MSGS[] = {
|
||||||
{0x50, 0, 16}, // LKAS
|
{0x50, 0, 16}, // LKAS
|
||||||
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
||||||
{426, 1, 16}, // CRUISE_BUTTON_ALT (clearpilot)
|
|
||||||
{0x2A4, 0, 24}, // CAM_0x2A4
|
{0x2A4, 0, 24}, // CAM_0x2A4
|
||||||
};
|
};
|
||||||
|
|
||||||
const CanMsg HYUNDAI_CANFD_HDA2_ALT_STEERING_TX_MSGS[] = {
|
const CanMsg HYUNDAI_CANFD_HDA2_ALT_STEERING_TX_MSGS[] = {
|
||||||
{0x110, 0, 32}, // LKAS_ALT
|
{0x110, 0, 32}, // LKAS_ALT
|
||||||
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
{0x1CF, 1, 8}, // CRUISE_BUTTON
|
||||||
{426, 1, 16}, // CRUISE_BUTTONS_ALT (clearpilot)
|
|
||||||
{0x362, 0, 32}, // CAM_0x362
|
{0x362, 0, 32}, // CAM_0x362
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -46,7 +44,6 @@ const CanMsg HYUNDAI_CANFD_HDA2_LONG_TX_MSGS[] = {
|
|||||||
{0x200, 1, 8}, // ADRV_0x200
|
{0x200, 1, 8}, // ADRV_0x200
|
||||||
{0x345, 1, 8}, // ADRV_0x345
|
{0x345, 1, 8}, // ADRV_0x345
|
||||||
{0x1DA, 1, 32}, // ADRV_0x1da
|
{0x1DA, 1, 32}, // ADRV_0x1da
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = {
|
const CanMsg HYUNDAI_CANFD_HDA1_TX_MSGS[] = {
|
||||||
@@ -246,47 +243,17 @@ static bool hyundai_canfd_tx_hook(const CANPacket_t *to_send) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// cruise buttons check
|
// cruise buttons check
|
||||||
// CLEARPILOT - Allow buttons 1 (accel), 2 (decel), 4 (pause/resume)
|
|
||||||
if (addr == 0x1cf) {
|
if (addr == 0x1cf) {
|
||||||
int button = GET_BYTE(to_send, 2) & 0x7U;
|
int button = GET_BYTE(to_send, 2) & 0x7U;
|
||||||
bool is_cancel = (button == HYUNDAI_BTN_CANCEL);
|
bool is_cancel = (button == HYUNDAI_BTN_CANCEL);
|
||||||
bool is_resume = (button == HYUNDAI_BTN_RESUME);
|
bool is_resume = (button == HYUNDAI_BTN_RESUME);
|
||||||
bool is_set_decel = (button == HYUNDAI_BTN_SET);
|
|
||||||
|
|
||||||
// bool allowed = (is_cancel && cruise_engaged_prev)
|
|
||||||
// Todo: allow is_cancel anytime speed > 0 on cruiseState
|
|
||||||
bool allowed = (is_cancel)
|
|
||||||
|| (is_resume && controls_allowed)
|
|
||||||
|| (is_set_decel && controls_allowed);
|
|
||||||
|
|
||||||
|
bool allowed = (is_cancel && cruise_engaged_prev) || (is_resume && controls_allowed);
|
||||||
if (!allowed) {
|
if (!allowed) {
|
||||||
tx = false;
|
tx = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CRUISE_BUTTONS_ALT
|
|
||||||
// if (addr == 426) {
|
|
||||||
// // this gets bit 16 we want bit 36
|
|
||||||
// int button = GET_BYTE(to_send, 2) & 0x7byteU;
|
|
||||||
// bool is_cancel = (button == HYUNDAI_BTN_CANCEL);
|
|
||||||
// bool is_resume = (button == HYUNDAI_BTN_RESUME);
|
|
||||||
// bool is_set_decel = (button == HYUNDAI_BTN_SET);
|
|
||||||
// // Canfd doc says there is a value 4 button allowed for canfd too, which one is it?
|
|
||||||
// // bool allowed = (is_cancel && cruise_engaged_prev)
|
|
||||||
// // Todo: allow is_cancel anytime speed > 0 on cruiseState
|
|
||||||
// bool allowed = (is_cancel)
|
|
||||||
// || (is_resume && controls_allowed)
|
|
||||||
// || (is_set_decel && controls_allowed);
|
|
||||||
|
|
||||||
// if (!allowed) {
|
|
||||||
// tx = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// CLEARPILOT - Allow DRIVE_MODE2
|
|
||||||
// if (addr == 1144) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// UDS: only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address
|
// UDS: only tester present ("\x02\x3E\x80\x00\x00\x00\x00\x00") allowed on diagnostics address
|
||||||
if ((addr == 0x730) && hyundai_canfd_hda2) {
|
if ((addr == 0x730) && hyundai_canfd_hda2) {
|
||||||
if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) {
|
if ((GET_BYTES(to_send, 0, 4) != 0x00803E02U) || (GET_BYTES(to_send, 4, 4) != 0x0U)) {
|
||||||
@@ -390,4 +357,4 @@ const safety_hooks hyundai_canfd_hooks = {
|
|||||||
.get_counter = hyundai_canfd_get_counter,
|
.get_counter = hyundai_canfd_get_counter,
|
||||||
.get_checksum = hyundai_canfd_get_checksum,
|
.get_checksum = hyundai_canfd_get_checksum,
|
||||||
.compute_checksum = hyundai_common_canfd_compute_checksum,
|
.compute_checksum = hyundai_common_canfd_compute_checksum,
|
||||||
};
|
};
|
||||||
0
panda/board/safety/safty_hyundai_canfd.h.wip
Normal file
0
panda/board/safety/safty_hyundai_canfd.h.wip
Normal file
Reference in New Issue
Block a user