AP_Gernerator: FuelCell: rework error check to give error cleared msg

This commit is contained in:
Iampete1 2023-10-22 17:56:33 +01:00 committed by Andrew Tridgell
parent 3b3c94ea07
commit a00b6b6f86
2 changed files with 14 additions and 12 deletions

View File

@ -168,27 +168,29 @@ void AP_Generator_IE_FuelCell::check_status(const uint32_t now)
update_state_msg(); update_state_msg();
// Check error codes // Check error codes
char msg_txt[64]; check_for_err_code_if_changed();
if (check_for_err_code_if_changed(msg_txt, sizeof(msg_txt))) {
GCS_SEND_TEXT(MAV_SEVERITY_ALERT, "%s", msg_txt);
}
} }
// Check error codes and populate message with error code // Check error codes and populate message with error code
bool AP_Generator_IE_FuelCell::check_for_err_code_if_changed(char* msg_txt, uint8_t msg_len) void AP_Generator_IE_FuelCell::check_for_err_code_if_changed()
{ {
// Only check if there has been a change in error code // Only check if there has been a change in error code
if ((_err_code == _last_err_code) && (_sub_err_code == _last_sub_err_code)) { if ((_err_code == _last_err_code) && (_sub_err_code == _last_sub_err_code)) {
return false; return;
} }
if (check_for_err_code(msg_txt, msg_len) || check_for_warning_code(msg_txt, msg_len)) { char msg_txt[64];
_last_err_code = _err_code; if (check_for_err_code(msg_txt, sizeof(msg_txt)) || check_for_warning_code(msg_txt, sizeof(msg_txt))) {
_last_sub_err_code = _sub_err_code; GCS_SEND_TEXT(MAV_SEVERITY_ALERT, "%s", msg_txt);
return true;
} else if ((_err_code == 0) && (_sub_err_code == 0)) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Fuel cell error cleared");
} }
return false; _last_err_code = _err_code;
_last_sub_err_code = _sub_err_code;
} }
// Return true is fuel cell is in running state suitable for arming // Return true is fuel cell is in running state suitable for arming

View File

@ -109,7 +109,7 @@ protected:
virtual bool check_for_warning_code(char* msg_txt, uint8_t msg_len) const { return false; } virtual bool check_for_warning_code(char* msg_txt, uint8_t msg_len) const { return false; }
// Only check the error code if it has changed since we last checked // Only check the error code if it has changed since we last checked
bool check_for_err_code_if_changed(char* msg_txt, uint8_t msg_len); void check_for_err_code_if_changed();
// Return true is fuel cell is in running state suitable for arming // Return true is fuel cell is in running state suitable for arming
virtual bool is_running() const; virtual bool is_running() const;