add fan stall count to health (#1355)

* add fan stall count to health

* fix misra

---------

Co-authored-by: Comma Device <device@comma.ai>
This commit is contained in:
Adeeb Shihadeh
2023-04-20 13:30:56 -07:00
committed by GitHub
parent 0e2eb9c0f5
commit 3c75a8bc00
4 changed files with 8 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ struct fan_state_t {
uint8_t power;
float error_integral;
uint8_t stall_counter;
uint8_t total_stall_count;
uint8_t cooldown_counter;
} fan_state_t;
struct fan_state_t fan_state;
@@ -46,6 +47,7 @@ void fan_tick(void){
if (fan_state.stall_counter > FAN_STALL_THRESHOLD) {
// Stall detected, power cycling fan controller
current_board->set_fan_enabled(false);
fan_state.total_stall_count += 1U;
// clip integral, can't fully reset otherwise we may always be stuck in stall detection
fan_state.error_integral = MIN(0.0f, fan_state.error_integral);

View File

@@ -1,6 +1,6 @@
// When changing these structs, python/__init__.py needs to be kept up to date!
#define HEALTH_PACKET_VERSION 12
#define HEALTH_PACKET_VERSION 13
struct __attribute__((packed)) health_t {
uint32_t uptime_pkt;
uint32_t voltage_pkt;
@@ -26,6 +26,7 @@ struct __attribute__((packed)) health_t {
uint8_t fan_power;
uint8_t safety_rx_checks_invalid;
uint16_t spi_checksum_error_count;
uint8_t fan_stall_count;
};
#define CAN_HEALTH_PACKET_VERSION 4

View File

@@ -39,6 +39,7 @@ int get_health_pkt(void *dat) {
health->interrupt_load = interrupt_load;
health->fan_power = fan_state.power;
health->fan_stall_count = fan_state.total_stall_count;
return sizeof(*health);
}

View File

@@ -182,9 +182,9 @@ class Panda:
HW_TYPE_TRES = b'\x09'
CAN_PACKET_VERSION = 4
HEALTH_PACKET_VERSION = 12
HEALTH_PACKET_VERSION = 13
CAN_HEALTH_PACKET_VERSION = 4
HEALTH_STRUCT = struct.Struct("<IIIIIIIIIBBBBBBHBBBHfBBH")
HEALTH_STRUCT = struct.Struct("<IIIIIIIIIBBBBBBHBBBHfBBHB")
CAN_HEALTH_STRUCT = struct.Struct("<BIBBBBBBBBIIIIIIIHHBBB")
F2_DEVICES = (HW_TYPE_PEDAL, )
@@ -565,6 +565,7 @@ class Panda:
"fan_power": a[21],
"safety_rx_checks_invalid": a[22],
"spi_checksum_error_count": a[23],
"fan_stall_count": a[24],
}
@ensure_can_health_packet_version