Skip to content

Commit

Permalink
AP_Vehicle: log internal error and report bitmask to GCS
Browse files Browse the repository at this point in the history
AP_Vehicle.cpp: cast parameter bitmask as (unsigned) per Peter B.

rework per Peter B.

Co-authored-by: Peter Barker <[email protected]>
remove unnecessary send_internal_error_statustext function

remove Write_InternalError function
  • Loading branch information
nkruzan authored and peterbarker committed Aug 31, 2021
1 parent 2be49cb commit 0a236bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libraries/AP_Logger/AP_Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ enum class LogErrorSubsystem : uint8_t {
FAILSAFE_LEAK = 27,
PILOT_INPUT = 28,
FAILSAFE_VIBE = 29,
INTERNAL_ERROR = 30,
};

// bizarrely this enumeration has lots of duplicate values, offering
Expand Down Expand Up @@ -229,6 +230,8 @@ enum class LogErrorCode : uint8_t {
FAILED_CIRCLE_INIT = 4,
DEST_OUTSIDE_FENCE = 5,
RTL_MISSING_RNGFND = 6,
// subsystem specific error codes -- internal_error
INTERNAL_ERRORS_DETECTED = 1,

// parachute failed to deploy because of low altitude or landed
PARACHUTE_TOO_LOW = 2,
Expand Down
6 changes: 6 additions & 0 deletions libraries/AP_Vehicle/AP_Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ void AP_Vehicle::loop()
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "%s", banner_msg);
}
}
const uint32_t new_internal_errors = AP::internalerror().errors();
if(_last_internal_errors != new_internal_errors) {
AP::logger().Write_Error(LogErrorSubsystem::INTERNAL_ERROR, LogErrorCode::INTERNAL_ERRORS_DETECTED);
gcs().send_text(MAV_SEVERITY_CRITICAL, "Internal Errors %x", (unsigned)new_internal_errors);
_last_internal_errors = new_internal_errors;
}
}

/*
Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_Vehicle/AP_Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ class AP_Vehicle : public AP_HAL::HAL::Callbacks {
static AP_Vehicle *_singleton;

bool done_safety_init;

uint32_t _last_internal_errors; // backup of AP_InternalError::internal_errors bitmask
};

namespace AP {
Expand Down

0 comments on commit 0a236bc

Please sign in to comment.