mirror of https://github.com/commaai/panda.git
add pandaState.safetyRxChecksInvalid field (#1083)
* add fault for invalid safety RX checks * fix test build * debug * fix debug * fix test * just a bool in health
This commit is contained in:
parent
4248085d7c
commit
e987e6c639
|
@ -1,6 +1,6 @@
|
|||
// When changing these structs, python/__init__.py needs to be kept up to date!
|
||||
|
||||
#define HEALTH_PACKET_VERSION 10
|
||||
#define HEALTH_PACKET_VERSION 11
|
||||
|
||||
struct __attribute__((packed)) health_t {
|
||||
uint32_t uptime_pkt;
|
||||
|
@ -25,6 +25,7 @@ struct __attribute__((packed)) health_t {
|
|||
uint16_t alternative_experience_pkt;
|
||||
float interrupt_load;
|
||||
uint8_t fan_power;
|
||||
uint8_t safety_rx_checks_invalid;
|
||||
};
|
||||
|
||||
#define CAN_HEALTH_PACKET_VERSION 2
|
||||
|
|
|
@ -29,6 +29,7 @@ int get_health_pkt(void *dat) {
|
|||
health->alternative_experience_pkt = alternative_experience;
|
||||
health->power_save_enabled_pkt = (uint8_t)(power_save_status == POWER_SAVE_STATUS_ENABLED);
|
||||
health->heartbeat_lost_pkt = (uint8_t)(heartbeat_lost);
|
||||
health->safety_rx_checks_invalid = safety_rx_checks_invalid;
|
||||
|
||||
health->fault_status_pkt = fault_status;
|
||||
health->faults_pkt = faults;
|
||||
|
|
|
@ -164,6 +164,7 @@ int get_addr_check_index(CANPacket_t *to_push, AddrCheckStruct addr_list[], cons
|
|||
|
||||
// 1Hz safety function called by main. Now just a check for lagging safety messages
|
||||
void safety_tick(const addr_checks *rx_checks) {
|
||||
bool rx_checks_invalid = false;
|
||||
uint32_t ts = microsecond_timer_get();
|
||||
if (rx_checks != NULL) {
|
||||
for (int i=0; i < rx_checks->len; i++) {
|
||||
|
@ -176,8 +177,14 @@ void safety_tick(const addr_checks *rx_checks) {
|
|||
if (lagging) {
|
||||
controls_allowed = 0;
|
||||
}
|
||||
|
||||
if (lagging || !is_msg_valid(rx_checks->check, i)) {
|
||||
rx_checks_invalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
safety_rx_checks_invalid = rx_checks_invalid;
|
||||
}
|
||||
|
||||
void update_counter(AddrCheckStruct addr_list[], int index, uint8_t counter) {
|
||||
|
@ -339,6 +346,7 @@ int set_safety_hooks(uint16_t mode, uint16_t param) {
|
|||
|
||||
controls_allowed = false;
|
||||
relay_malfunction_reset();
|
||||
safety_rx_checks_invalid = false;
|
||||
|
||||
int set_status = -1; // not set
|
||||
int hook_config_count = sizeof(safety_hook_registry) / sizeof(safety_hook_config);
|
||||
|
|
|
@ -146,6 +146,7 @@ float vehicle_speed = 0;
|
|||
bool vehicle_moving = false;
|
||||
bool acc_main_on = false; // referred to as "ACC off" in ISO 15622:2018
|
||||
int cruise_button_prev = 0;
|
||||
bool safety_rx_checks_invalid = false;
|
||||
|
||||
// for safety modes with torque steering control
|
||||
int desired_torque_last = 0; // last desired steer torque
|
||||
|
|
|
@ -185,9 +185,9 @@ class Panda:
|
|||
HW_TYPE_RED_PANDA_V2 = b'\x08'
|
||||
|
||||
CAN_PACKET_VERSION = 2
|
||||
HEALTH_PACKET_VERSION = 10
|
||||
HEALTH_PACKET_VERSION = 11
|
||||
CAN_HEALTH_PACKET_VERSION = 2
|
||||
HEALTH_STRUCT = struct.Struct("<IIIIIIIIIBBBBBBHBBBHfB")
|
||||
HEALTH_STRUCT = struct.Struct("<IIIIIIIIIBBBBBBHBBBHfBB")
|
||||
CAN_HEALTH_STRUCT = struct.Struct("<BIBBBBBBBBIIIIIIHHBB")
|
||||
|
||||
F2_DEVICES = (HW_TYPE_PEDAL, )
|
||||
|
@ -470,6 +470,7 @@ class Panda:
|
|||
"alternative_experience": a[19],
|
||||
"interrupt_load": a[20],
|
||||
"fan_power": a[21],
|
||||
"safety_rx_checks_invalid": a[22],
|
||||
}
|
||||
|
||||
@ensure_can_health_packet_version
|
||||
|
|
Loading…
Reference in New Issue