forked from IQ.Lvbs/IQ.Pilot
IQ.Pilot Release Commit @ 0798119
This commit is contained in:
40
iqdbc_repo/iqdbc/safety/modes/elm327.h
Normal file
40
iqdbc_repo/iqdbc/safety/modes/elm327.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
#include "iqdbc/safety/declarations.h"
|
||||
#include "iqdbc/safety/modes/defaults.h"
|
||||
|
||||
static bool elm327_tx_hook(const CANPacket_t *msg) {
|
||||
const unsigned int GM_CAMERA_DIAG_ADDR = 0x24BU;
|
||||
|
||||
bool tx = true;
|
||||
int len = GET_LEN(msg);
|
||||
|
||||
// All ISO 15765-4 messages must be 8 bytes long
|
||||
if (len != 8) {
|
||||
tx = false;
|
||||
}
|
||||
|
||||
// Check valid 29 bit send addresses for ISO 15765-4
|
||||
// Check valid 11 bit send addresses for ISO 15765-4
|
||||
if ((msg->addr != 0x18DB33F1U) && ((msg->addr & 0x1FFF00FFU) != 0x18DA00F1U) &&
|
||||
((msg->addr & 0x1FFFFF00U) != 0x600U) && ((msg->addr & 0x1FFFFF00U) != 0x700U) &&
|
||||
(msg->addr != GM_CAMERA_DIAG_ADDR)) {
|
||||
tx = false;
|
||||
}
|
||||
|
||||
// GM camera uses non-standard diagnostic address, this has no control message address collisions
|
||||
if ((msg->addr == GM_CAMERA_DIAG_ADDR) && (len == 8)) {
|
||||
// Only allow known frame types for ISO 15765-2
|
||||
if ((msg->data[0] & 0xF0U) > 0x30U) {
|
||||
tx = false;
|
||||
}
|
||||
}
|
||||
return tx;
|
||||
}
|
||||
|
||||
// If safety_param == 0, bus 1 is multiplexed to the OBD-II port
|
||||
const safety_hooks elm327_hooks = {
|
||||
.init = nooutput_init,
|
||||
.rx = default_rx_hook,
|
||||
.tx = elm327_tx_hook,
|
||||
};
|
||||
Reference in New Issue
Block a user