You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.6 KiB
52 lines
1.6 KiB
2 months ago
|
#pragma once
|
||
2 years ago
|
|
||
2 days ago
|
#include "opendbc/safety/safety_declarations.h"
|
||
2 years ago
|
|
||
1 year ago
|
static void body_rx_hook(const CANPacket_t *to_push) {
|
||
2 years ago
|
// body is never at standstill
|
||
|
vehicle_moving = true;
|
||
|
|
||
1 year ago
|
if (GET_ADDR(to_push) == 0x201U) {
|
||
2 years ago
|
controls_allowed = true;
|
||
|
}
|
||
2 years ago
|
}
|
||
|
|
||
1 year ago
|
static bool body_tx_hook(const CANPacket_t *to_send) {
|
||
|
bool tx = true;
|
||
2 years ago
|
int addr = GET_ADDR(to_send);
|
||
2 years ago
|
int len = GET_LEN(to_send);
|
||
2 years ago
|
|
||
1 year ago
|
if (!controls_allowed && (addr != 0x1)) {
|
||
|
tx = false;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// Allow going into CAN flashing mode for base & knee even if controls are not allowed
|
||
|
bool flash_msg = ((addr == 0x250) || (addr == 0x350)) && (len == 8);
|
||
|
if (!controls_allowed && (GET_BYTES(to_send, 0, 4) == 0xdeadfaceU) && (GET_BYTES(to_send, 4, 4) == 0x0ab00b1eU) && flash_msg) {
|
||
1 year ago
|
tx = true;
|
||
2 years ago
|
}
|
||
|
|
||
|
return tx;
|
||
|
}
|
||
|
|
||
1 year ago
|
static safety_config body_init(uint16_t param) {
|
||
2 months ago
|
static RxCheck body_rx_checks[] = {
|
||
|
{.msg = {{0x201, 0, 8, .ignore_checksum = true, .ignore_counter = true, .frequency = 100U}, { 0 }, { 0 }}},
|
||
|
};
|
||
|
|
||
2 days ago
|
static const CanMsg BODY_TX_MSGS[] = {{0x250, 0, 8, .check_relay = false}, {0x250, 0, 6, .check_relay = false}, {0x251, 0, 5, .check_relay = false}, // body
|
||
|
{0x350, 0, 8, .check_relay = false}, {0x350, 0, 6, .check_relay = false}, {0x351, 0, 5, .check_relay = false}, // knee
|
||
|
{0x1, 0, 8, .check_relay = false}}; // CAN flasher
|
||
2 months ago
|
|
||
2 years ago
|
UNUSED(param);
|
||
2 months ago
|
safety_config ret = BUILD_SAFETY_CFG(body_rx_checks, BODY_TX_MSGS);
|
||
|
ret.disable_forwarding = true;
|
||
|
return ret;
|
||
2 years ago
|
}
|
||
|
|
||
|
const safety_hooks body_hooks = {
|
||
|
.init = body_init,
|
||
|
.rx = body_rx_hook,
|
||
|
.tx = body_tx_hook,
|
||
|
};
|