Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_Generator: IE 2400: MAV_SEVERITY level depends on error code #26461

Merged
merged 1 commit into from Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions libraries/AP_Generator/AP_Generator_IE_2400.cpp
Expand Up @@ -562,4 +562,18 @@ void AP_Generator_IE_2400::update_state_msg()
}
}

#if HAL_GCS_ENABLED
// Get the MAV_SEVERITY level of a given error code
MAV_SEVERITY AP_Generator_IE_2400::get_mav_severity(uint32_t err_code) const
{
if (err_code <= 9) {
return MAV_SEVERITY_INFO;
}
if (err_code <= 20) {
return MAV_SEVERITY_WARNING;
}
return MAV_SEVERITY_CRITICAL;
}
#endif // HAL_GCS_ENABLED

#endif // AP_GENERATOR_IE_2400_ENABLED
5 changes: 5 additions & 0 deletions libraries/AP_Generator/AP_Generator_IE_2400.h
Expand Up @@ -39,6 +39,11 @@ class AP_Generator_IE_2400 : public AP_Generator_IE_FuelCell
// Check if we have received an warning code and populate message with warning code
bool check_for_warning_code(char* msg_txt, uint8_t msg_len) const override;

#if HAL_GCS_ENABLED
// Get the MAV_SEVERITY level of a given error code
MAV_SEVERITY get_mav_severity(uint32_t err_code) const override;
#endif

// Check for error codes that are deemed critical
bool is_critical_error(const uint32_t err_in) const;

Expand Down
4 changes: 3 additions & 1 deletion libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp
Expand Up @@ -179,14 +179,16 @@ void AP_Generator_IE_FuelCell::check_for_err_code_if_changed()
return;
}

#if HAL_GCS_ENABLED
char msg_txt[64];
if (check_for_err_code(msg_txt, sizeof(msg_txt)) || check_for_warning_code(msg_txt, sizeof(msg_txt))) {
GCS_SEND_TEXT(MAV_SEVERITY_ALERT, "%s", msg_txt);
GCS_SEND_TEXT(get_mav_severity(_err_code), "%s", msg_txt);

} else if ((_err_code == 0) && (_sub_err_code == 0)) {
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "Fuel cell error cleared");

}
#endif

_last_err_code = _err_code;
_last_sub_err_code = _sub_err_code;
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_Generator/AP_Generator_IE_FuelCell.h
Expand Up @@ -5,6 +5,7 @@
#if AP_GENERATOR_IE_ENABLED

#include <AP_Logger/AP_Logger_config.h>
#include <GCS_MAVLink/GCS.h>

class AP_Generator_IE_FuelCell : public AP_Generator_Backend
{
Expand Down Expand Up @@ -117,5 +118,10 @@ class AP_Generator_IE_FuelCell : public AP_Generator_Backend
// Print msg to user updating on state change
virtual void update_state_msg();

#if HAL_GCS_ENABLED
// Get the MAV_SEVERITY level of a given error code
virtual MAV_SEVERITY get_mav_severity(uint32_t err_code) const { return MAV_SEVERITY_ALERT; }
#endif

};
#endif // AP_GENERATOR_IE_ENABLED