Mazda: CAN ignition (#758)

This commit is contained in:
Adeeb Shihadeh 2021-10-30 15:32:27 -07:00 committed by GitHub
parent bf77a0b20c
commit 2e5de6e99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -193,23 +193,30 @@ void ignition_can_hook(CAN_FIFOMailBox_TypeDef *to_push) {
ignition_can_cnt = 0U; // reset counter
if (bus == 0) {
// GM exception
// TODO: verify on all supported GM models that we can reliably detect ignition using only this signal,
// since the 0x1F1 signal can briefly go low immediately after ignition
if ((addr == 0x160) && (len == 5)) {
// this message isn't all zeros when ignition is on
ignition_cadillac = GET_BYTES_04(to_push) != 0;
}
// GM exception
if ((addr == 0x1F1) && (len == 8)) {
// Bit 5 is ignition "on"
bool ignition_gm = ((GET_BYTE(to_push, 0) & 0x20) != 0);
ignition_can = ignition_gm || ignition_cadillac;
}
// Tesla exception
if ((addr == 0x348) && (len == 8)) {
// GTW_status
ignition_can = (GET_BYTE(to_push, 0) & 0x1) != 0;
}
// Mazda exception
if ((addr == 0x9E) && (len == 8)) {
ignition_can = (GET_BYTE(to_push, 0) >> 4) == 0xDU;
}
}
}