diff --git a/src/ErrorHandling.c b/src/ErrorHandling.c index ceb0ed52..a2f320de 100644 --- a/src/ErrorHandling.c +++ b/src/ErrorHandling.c @@ -109,24 +109,24 @@ void motoRosAssert_withMsg(BOOL mustBeTrue, ALARM_ASSERTION_FAIL_SUBCODE subCode } } -void motoRos_RCLAssertOK(int code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse) +void motoRos_RCLAssertOK(int rcl_return_code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse) { - motoRos_RCLAssertOK_withMsg(code, subCodeIfFalse, APPLICATION_NAME ": Fatal Error"); + motoRos_RCLAssertOK_withMsg(rcl_return_code, subCodeIfFalse, APPLICATION_NAME ": Fatal Error"); } -void motoRos_RCLAssertOK_withMsg(int code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse, char* msgFmtIfFalse, ...) +void motoRos_RCLAssertOK_withMsg(int rcl_return_code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse, char* msgFmtIfFalse, ...) { char rcl_api_msg[ERROR_MSG_MAX_SIZE]; char assert_msg[ERROR_MSG_MAX_SIZE]; va_list va; - if (code == RCL_RET_OK) + if (rcl_return_code == RCL_RET_OK) return; bzero(rcl_api_msg, ERROR_MSG_MAX_SIZE); bzero(assert_msg, ERROR_MSG_MAX_SIZE); - snprintf(rcl_api_msg, ERROR_MSG_MAX_SIZE, "RCL(C) API error: %d", code); + snprintf(rcl_api_msg, ERROR_MSG_MAX_SIZE, "RCL(C) API error: %d", rcl_return_code); va_start(va, msgFmtIfFalse); vsnprintf(assert_msg, ERROR_MSG_MAX_SIZE, msgFmtIfFalse, va); diff --git a/src/ErrorHandling.h b/src/ErrorHandling.h index de9ca090..ab98971d 100644 --- a/src/ErrorHandling.h +++ b/src/ErrorHandling.h @@ -229,10 +229,41 @@ typedef enum SUBCODE_RCL_RCLC_API_ERROR, } ALARM_RCL_RCLC_FAIL_SUBCODE; //8017 +/// +/// If the condition is TRUE, raise a fatal alarm on the pendant and block further execution. +/// +/// Condition to validate. Assertion will occur if FALSE. +/// Context-specific alarm [subcode] to display on the pendant. extern void motoRosAssert(BOOL mustBeTrue, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse); + +/// +/// If the condition is TRUE, raise a fatal alarm on the pendant and block further execution. +/// A context-specific message is included to help the user understand the error. +/// +/// Condition to validate. Assertion will occur if FALSE. +/// Context-specific alarm [subcode] to display on the pendant. +/// Format-string msge to display to the user. extern void motoRosAssert_withMsg(BOOL mustBeTrue, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse, char* msgFmtIfFalse, ...); -extern void motoRos_RCLAssertOK(int code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse); -extern void motoRos_RCLAssertOK_withMsg(int code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse, char* msgFmtIfFalse, ...); + +/// +/// Validate that an RCL return value is OK. If the return code is anything other than OK, +/// then raise a fatal alarm on the pendant and block further execution. The alarm will +/// indicate both a context-specific MotoROS2 code and also the RCL return code. +/// +/// RCL return code to verify is OK. Assertion will occur if not OK. +/// Context-specific alarm [subcode] to display in addition to the RCL return code. +extern void motoRos_RCLAssertOK(int rcl_return_code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse); + +/// +/// Validate that an RCL return value is OK. If the return code is anything other than OK, +/// then raise a fatal alarm on the pendant and block further execution. The alarm will +/// indicate both a context-specific MotoROS2 code and also the RCL return code. An additional +/// message will be displayed to help the user understand the error. +/// +/// RCL return code to verify is OK. Assertion will occur if not OK. +/// Context-specific alarm [subcode] to display in addition to the RCL return code. +/// Format-string msge to display to the user. +extern void motoRos_RCLAssertOK_withMsg(int rcl_return_code, ALARM_ASSERTION_FAIL_SUBCODE subCodeIfFalse, char* msgFmtIfFalse, ...); extern const char* const Ros_ErrorHandling_ErrNo_ToString(int errNo); extern const char* const Ros_ErrorHandling_MotionNotReadyCode_ToString(MotionNotReadyCode code);