mirror of
https://github.com/infiniteCable2/panda.git
synced 2026-02-18 17:23:52 +08:00
Make safety param uint16_t (#931)
* change safety param to uint16_t * accidental paste
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// When changing this struct, python/__init__.py needs to be kept up to date!
|
||||
#define HEALTH_PACKET_VERSION 6
|
||||
#define HEALTH_PACKET_VERSION 7
|
||||
struct __attribute__((packed)) health_t {
|
||||
uint32_t uptime_pkt;
|
||||
uint32_t voltage_pkt;
|
||||
@@ -16,7 +16,7 @@ struct __attribute__((packed)) health_t {
|
||||
uint8_t car_harness_status_pkt;
|
||||
uint8_t usb_power_mode_pkt;
|
||||
uint8_t safety_mode_pkt;
|
||||
uint32_t safety_param_pkt;
|
||||
uint16_t safety_param_pkt;
|
||||
uint8_t fault_status_pkt;
|
||||
uint8_t power_save_enabled_pkt;
|
||||
uint8_t heartbeat_lost_pkt;
|
||||
|
||||
@@ -69,7 +69,7 @@ void debug_ring_callback(uart_ring *ring) {
|
||||
// ****************************** safety mode ******************************
|
||||
|
||||
// this is the only way to leave silent mode
|
||||
void set_safety_mode(uint16_t mode, uint32_t param) {
|
||||
void set_safety_mode(uint16_t mode, uint16_t param) {
|
||||
uint16_t mode_copy = mode;
|
||||
int err = set_safety_hooks(mode_copy, param);
|
||||
if (err == -1) {
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#define SAFETY_BODY 27U
|
||||
|
||||
uint16_t current_safety_mode = SAFETY_SILENT;
|
||||
uint32_t current_safety_param = 0;
|
||||
uint16_t current_safety_param = 0;
|
||||
const safety_hooks *current_hooks = &nooutput_hooks;
|
||||
const addr_checks *current_rx_checks = &default_rx_checks;
|
||||
|
||||
@@ -262,7 +262,7 @@ const safety_hook_config safety_hook_registry[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
int set_safety_hooks(uint16_t mode, uint32_t param) {
|
||||
int set_safety_hooks(uint16_t mode, uint16_t param) {
|
||||
// reset state set by safety mode
|
||||
safety_mode_cnt = 0U;
|
||||
relay_malfunction = false;
|
||||
|
||||
@@ -31,7 +31,7 @@ static int body_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
static const addr_checks* body_init(uint32_t param) {
|
||||
static const addr_checks* body_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -196,7 +196,7 @@ static int chrysler_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* chrysler_init(uint32_t param) {
|
||||
static const addr_checks* chrysler_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -10,7 +10,7 @@ int default_rx_hook(CANPacket_t *to_push) {
|
||||
|
||||
// *** no output safety mode ***
|
||||
|
||||
static const addr_checks* nooutput_init(uint32_t param) {
|
||||
static const addr_checks* nooutput_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
@@ -50,7 +50,7 @@ const safety_hooks nooutput_hooks = {
|
||||
const uint16_t ALLOUTPUT_PARAM_PASSTHROUGH = 1;
|
||||
bool alloutput_passthrough = false;
|
||||
|
||||
static const addr_checks* alloutput_init(uint32_t param) {
|
||||
static const addr_checks* alloutput_init(uint16_t param) {
|
||||
alloutput_passthrough = GET_FLAG(param, ALLOUTPUT_PARAM_PASSTHROUGH);
|
||||
controls_allowed = true;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -219,7 +219,7 @@ static int gm_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
static const addr_checks* gm_init(uint32_t param) {
|
||||
static const addr_checks* gm_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -362,7 +362,7 @@ static int honda_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
static const addr_checks* honda_nidec_init(uint32_t param) {
|
||||
static const addr_checks* honda_nidec_init(uint16_t param) {
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
gas_interceptor_detected = 0;
|
||||
@@ -378,7 +378,7 @@ static const addr_checks* honda_nidec_init(uint32_t param) {
|
||||
return &honda_rx_checks;
|
||||
}
|
||||
|
||||
static const addr_checks* honda_bosch_init(uint32_t param) {
|
||||
static const addr_checks* honda_bosch_init(uint16_t param) {
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
honda_hw = HONDA_BOSCH;
|
||||
|
||||
@@ -377,7 +377,7 @@ static int hyundai_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* hyundai_init(uint32_t param) {
|
||||
static const addr_checks* hyundai_init(uint16_t param) {
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -398,7 +398,7 @@ static const addr_checks* hyundai_init(uint32_t param) {
|
||||
return &hyundai_rx_checks;
|
||||
}
|
||||
|
||||
static const addr_checks* hyundai_legacy_init(uint32_t param) {
|
||||
static const addr_checks* hyundai_legacy_init(uint16_t param) {
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ static int mazda_fwd_hook(int bus, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* mazda_init(uint32_t param) {
|
||||
static const addr_checks* mazda_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -189,7 +189,7 @@ static int nissan_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* nissan_init(uint32_t param) {
|
||||
static const addr_checks* nissan_init(uint16_t param) {
|
||||
controls_allowed = 0;
|
||||
nissan_alt_eps = param ? 1 : 0;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -313,7 +313,7 @@ static int subaru_legacy_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* subaru_init(uint32_t param) {
|
||||
static const addr_checks* subaru_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
@@ -328,7 +328,7 @@ const safety_hooks subaru_hooks = {
|
||||
.fwd = subaru_fwd_hook,
|
||||
};
|
||||
|
||||
static const addr_checks* subaru_legacy_init(uint32_t param) {
|
||||
static const addr_checks* subaru_legacy_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
|
||||
@@ -244,7 +244,7 @@ static int tesla_fwd_hook(int bus_num, CANPacket_t *to_fwd) {
|
||||
return bus_fwd;
|
||||
}
|
||||
|
||||
static const addr_checks* tesla_init(uint32_t param) {
|
||||
static const addr_checks* tesla_init(uint16_t param) {
|
||||
tesla_powertrain = GET_FLAG(param, TESLA_FLAG_POWERTRAIN);
|
||||
tesla_longitudinal = GET_FLAG(param, TESLA_FLAG_LONGITUDINAL_CONTROL);
|
||||
controls_allowed = 0;
|
||||
|
||||
@@ -263,7 +263,7 @@ static int toyota_tx_hook(CANPacket_t *to_send, bool longitudinal_allowed) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
static const addr_checks* toyota_init(uint32_t param) {
|
||||
static const addr_checks* toyota_init(uint16_t param) {
|
||||
controls_allowed = 0;
|
||||
relay_malfunction_reset();
|
||||
gas_interceptor_detected = 0;
|
||||
|
||||
@@ -76,7 +76,7 @@ static uint8_t volkswagen_mqb_compute_crc(CANPacket_t *to_push) {
|
||||
return crc ^ 0xFFU;
|
||||
}
|
||||
|
||||
static const addr_checks* volkswagen_mqb_init(uint32_t param) {
|
||||
static const addr_checks* volkswagen_mqb_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
|
||||
controls_allowed = false;
|
||||
|
||||
@@ -49,7 +49,7 @@ static uint8_t volkswagen_pq_compute_checksum(CANPacket_t *to_push) {
|
||||
return checksum;
|
||||
}
|
||||
|
||||
static const addr_checks* volkswagen_pq_init(uint32_t param) {
|
||||
static const addr_checks* volkswagen_pq_init(uint16_t param) {
|
||||
UNUSED(param);
|
||||
|
||||
controls_allowed = false;
|
||||
|
||||
@@ -84,7 +84,7 @@ void generic_rx_checks(bool stock_ecu_detected);
|
||||
void relay_malfunction_set(void);
|
||||
void relay_malfunction_reset(void);
|
||||
|
||||
typedef const addr_checks* (*safety_hook_init)(uint32_t param);
|
||||
typedef const addr_checks* (*safety_hook_init)(uint16_t param);
|
||||
typedef int (*rx_hook)(CANPacket_t *to_push);
|
||||
typedef int (*tx_hook)(CANPacket_t *to_send, bool longitudinal_allowed);
|
||||
typedef int (*tx_lin_hook)(int lin_num, uint8_t *data, int len);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
extern int _app_start[0xc000]; // Only first 3 sectors of size 0x4000 are used
|
||||
|
||||
// Prototypes
|
||||
void set_safety_mode(uint16_t mode, uint32_t param);
|
||||
void set_safety_mode(uint16_t mode, uint16_t param);
|
||||
bool is_car_safety_mode(uint16_t mode);
|
||||
|
||||
int get_health_pkt(void *dat) {
|
||||
@@ -273,7 +273,7 @@ int usb_cb_control_msg(USB_Setup_TypeDef *setup, uint8_t *resp) {
|
||||
|
||||
// **** 0xdc: set safety mode
|
||||
case 0xdc:
|
||||
set_safety_mode(setup->b.wValue.w, (uint32_t) setup->b.wIndex.w);
|
||||
set_safety_mode(setup->b.wValue.w, (uint16_t)setup->b.wIndex.w);
|
||||
break;
|
||||
// **** 0xdd: get healthpacket and CANPacket versions
|
||||
case 0xdd:
|
||||
|
||||
@@ -170,8 +170,8 @@ class Panda(object):
|
||||
HW_TYPE_RED_PANDA = b'\x07'
|
||||
|
||||
CAN_PACKET_VERSION = 2
|
||||
HEALTH_PACKET_VERSION = 6
|
||||
HEALTH_STRUCT = struct.Struct("<IIIIIIIIBBBBBBBIBBBHIf")
|
||||
HEALTH_PACKET_VERSION = 7
|
||||
HEALTH_STRUCT = struct.Struct("<IIIIIIIIBBBBBBBHBBBHIf")
|
||||
|
||||
F2_DEVICES = (HW_TYPE_PEDAL, )
|
||||
F4_DEVICES = (HW_TYPE_WHITE_PANDA, HW_TYPE_GREY_PANDA, HW_TYPE_BLACK_PANDA, HW_TYPE_UNO, HW_TYPE_DOS)
|
||||
|
||||
@@ -57,7 +57,7 @@ void set_timer(uint32_t t);
|
||||
int safety_rx_hook(CANPacket_t *to_send);
|
||||
int safety_tx_hook(CANPacket_t *to_push);
|
||||
int safety_fwd_hook(int bus_num, CANPacket_t *to_fwd);
|
||||
int set_safety_hooks(uint16_t mode, uint32_t param);
|
||||
int set_safety_hooks(uint16_t mode, uint16_t param);
|
||||
|
||||
void safety_tick_current_rx_checks();
|
||||
bool addr_checks_valid();
|
||||
|
||||
Reference in New Issue
Block a user