Send AMS error messages

This commit is contained in:
2023-04-30 00:57:42 +02:00
parent 48ae56fbdf
commit ce4d7253eb
6 changed files with 34 additions and 1 deletions

View File

@ -1,5 +1,6 @@
#include "slave_monitoring.h"
#include "can.h"
#include "main.h"
#include "ts_state_machine.h"
@ -60,14 +61,18 @@ void slaves_check() {
uint16_t min_voltage_new = 0xFFFF;
int16_t max_temp_new = 0xFFFF;
for (int i = 0; i < N_SLAVES; i++) {
// Update timeout errors
if (now - slaves[i].last_message >= SLAVE_TIMEOUT) {
// Don't overwrite a different error kind
if (slaves[i].error.kind == SLAVE_ERR_NONE) {
slaves[i].error.kind = SLAVE_ERR_TIMEOUT;
can_send_error(TS_ERRORKIND_SLAVE_TIMEOUT, slaves[i].id);
}
} else if (slaves[i].error.kind == SLAVE_ERR_TIMEOUT) {
slaves[i].error.kind = SLAVE_ERR_NONE;
}
// Determine min/max
if (slaves[i].min_voltage < min_voltage_new) {
min_voltage_new = slaves[i].min_voltage;
}
@ -107,6 +112,7 @@ void slaves_handle_panic(const uint8_t *data) {
}
slaves[idx].error.data = ftcan_unmarshal_unsigned(&data, 4);
slaves[idx].last_message = HAL_GetTick();
can_send_error(TS_ERRORKIND_SLAVE_PANIC, slave_id);
}
void slaves_handle_status(const uint8_t *data) {