Splitting MBED_ERROR macros to support ones with/without error value argument

pull/6983/head
Senthil Ramakrishnan 2018-05-23 12:19:09 -05:00
parent 693a6c40bb
commit 5ef6728c08
12 changed files with 99 additions and 91 deletions

View File

@ -30,7 +30,7 @@ void test_error_count_and_reset()
//Log multiple errors and get the error count and make sure its 15
for(int i=0; i<count; i++) {
MBED_WARNING(MBED_ERROR_OUT_OF_MEMORY, "Out of memory", i);
MBED_WARNING1(MBED_ERROR_OUT_OF_MEMORY, "Out of memory", i);
}
TEST_ASSERT_EQUAL_INT(count, mbed_get_error_count());
@ -53,28 +53,28 @@ void test_error_capturing()
//first clear all errors and start afresh
MBED_WARNING(MBED_ERROR_OUT_OF_RESOURCES, "System type error", 0x1100 );
MBED_WARNING1(MBED_ERROR_OUT_OF_RESOURCES, "System type error", 0x1100 );
mbed_error_status_t lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TYPE_SYSTEM, MBED_GET_ERROR_TYPE(lastError));
TEST_ASSERT_EQUAL_UINT(MBED_MODULE_UNKNOWN, MBED_GET_ERROR_MODULE(lastError));
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_CODE_OUT_OF_RESOURCES, MBED_GET_ERROR_CODE(lastError));
mbed_error_status_t error = MBED_MAKE_ERROR(MBED_MODULE_DRIVER_SERIAL, MBED_ERROR_CODE_OUT_OF_RESOURCES);
MBED_WARNING(error, "Error Serial", 0xAA );
MBED_WARNING1(error, "Error Serial", 0xAA );
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(error, lastError);
error = MBED_MAKE_CUSTOM_ERROR(MBED_MODULE_APPLICATION, MBED_ERROR_CODE_UNKNOWN);
MBED_WARNING(error, "Custom Error Unknown", 0x1234 );
MBED_WARNING1(error, "Custom Error Unknown", 0x1234 );
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(error, lastError);
MBED_WARNING(MBED_ERROR_EPERM, "Posix Error Eperm", 0x1234 );
MBED_WARNING1(MBED_ERROR_EPERM, "Posix Error Eperm", 0x1234 );
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_EPERM, lastError);
error = MBED_MAKE_CUSTOM_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CREATE_FAILED);
MBED_WARNING(error, "Custom Error Type", error_value);
MBED_WARNING1(error, "Custom Error Type", error_value);
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TYPE_CUSTOM, MBED_GET_ERROR_TYPE(lastError));
TEST_ASSERT_EQUAL_UINT(MBED_MODULE_PLATFORM, MBED_GET_ERROR_MODULE(lastError));
@ -84,7 +84,7 @@ void test_error_capturing()
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
error_value = 0xAABBCC;
MBED_WARNING(MBED_ERROR_EACCES, "Posix Error", error_value );
MBED_WARNING1(MBED_ERROR_EACCES, "Posix Error", error_value );
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TYPE_POSIX, MBED_GET_ERROR_TYPE(lastError));
TEST_ASSERT_EQUAL_UINT(MBED_MODULE_UNKNOWN, MBED_GET_ERROR_MODULE(lastError));
@ -95,7 +95,7 @@ void test_error_capturing()
error_value = 0;
error = MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNKNOWN);
MBED_WARNING(error, "HAL Entity error", error_value );
MBED_WARNING1(error, "HAL Entity error", error_value );
lastError = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TYPE_SYSTEM, MBED_GET_ERROR_TYPE(lastError));
TEST_ASSERT_EQUAL_UINT(MBED_MODULE_HAL, MBED_GET_ERROR_MODULE(lastError));
@ -104,7 +104,7 @@ void test_error_capturing()
TEST_ASSERT(status == MBED_SUCCESS);
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
MBED_WARNING(MBED_ERROR_MUTEX_LOCK_FAILED, "Mutex lock failed", 0x4455 );
MBED_WARNING1(MBED_ERROR_MUTEX_LOCK_FAILED, "Mutex lock failed", 0x4455 );
error = mbed_get_last_error();
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_MUTEX_LOCK_FAILED, error);
@ -120,7 +120,7 @@ void test_error_context_capture()
uint32_t error_value = 0xABCD;
mbed_error_ctx error_ctx = {0};
MBED_WARNING(MBED_ERROR_INVALID_ARGUMENT, "System type error", error_value );
MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "System type error", error_value );
mbed_error_status_t status = mbed_get_last_error_info( &error_ctx );
TEST_ASSERT(status == MBED_SUCCESS);
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
@ -147,9 +147,9 @@ void test_error_logging()
mbed_clear_all_errors();
//log 3 errors and retrieve them to ensure they are correct
MBED_WARNING(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 1 );
MBED_WARNING(MBED_ERROR_INVALID_SIZE, "Invalid size", 2 );
MBED_WARNING(MBED_ERROR_INVALID_FORMAT, "Invalid format", 3 );
MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 1 );
MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 2 );
MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 3 );
mbed_error_status_t status = mbed_get_error_hist_info( 0, &error_ctx );
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_INVALID_ARGUMENT, error_ctx.error_status);
@ -164,16 +164,16 @@ void test_error_logging()
TEST_ASSERT_EQUAL_UINT(3, error_ctx.error_value);
//Log a bunch of errors to overflow the error log and retrieve them
MBED_WARNING(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 6 );
MBED_WARNING(MBED_ERROR_INVALID_SIZE, "Invalid size", 7 );
MBED_WARNING(MBED_ERROR_INVALID_FORMAT, "Invalid format", 8 );
MBED_WARNING(MBED_ERROR_NOT_READY, "Not ready error", 9 );
MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Invalid argument", 6 );
MBED_WARNING1(MBED_ERROR_INVALID_SIZE, "Invalid size", 7 );
MBED_WARNING1(MBED_ERROR_INVALID_FORMAT, "Invalid format", 8 );
MBED_WARNING1(MBED_ERROR_NOT_READY, "Not ready error", 9 );
//Last 4 entries
MBED_WARNING(MBED_ERROR_TIME_OUT, "Timeout error", 10 );
MBED_WARNING(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 11 );
MBED_WARNING(MBED_ERROR_UNSUPPORTED, "Not supported", 12 );
MBED_WARNING(MBED_ERROR_ACCESS_DENIED, "Access denied", 13 );
MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 10 );
MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 11 );
MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported", 12 );
MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied", 13 );
status = mbed_get_error_hist_info( 0, &error_ctx );
TEST_ASSERT_EQUAL_UINT(MBED_ERROR_TIME_OUT, error_ctx.error_status);
@ -202,7 +202,7 @@ void test_error_logging()
//Error logger threads
void err_thread_func(mbed_error_status_t *error_status)
{
MBED_WARNING(*error_status, "Error from Multi-Threaded error logging test", *error_status );
MBED_WARNING1(*error_status, "Error from Multi-Threaded error logging test", *error_status );
}
@ -254,7 +254,7 @@ void test_error_hook()
TEST_FAIL();
}
MBED_WARNING(MBED_ERROR_INVALID_ARGUMENT, "Test for error hook", 1234);
MBED_WARNING1(MBED_ERROR_INVALID_ARGUMENT, "Test for error hook", 1234);
int32_t sem_status = callback_sem.wait(5000);
TEST_ASSERT(sem_status > 0);
@ -295,11 +295,11 @@ MBED_TEST_SIM_BLOCKDEVICE_DECL;
void test_save_error_log()
{
//Log some errors
MBED_WARNING(MBED_ERROR_TIME_OUT, "Timeout error", 1 );
MBED_WARNING(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 2 );
MBED_WARNING(MBED_ERROR_UNSUPPORTED, "Not supported error", 3 );
MBED_WARNING(MBED_ERROR_ACCESS_DENIED, "Access denied error", 4 );
MBED_WARNING(MBED_ERROR_ITEM_NOT_FOUND, "Not found error", 5 );
MBED_WARNING1(MBED_ERROR_TIME_OUT, "Timeout error", 1 );
MBED_WARNING1(MBED_ERROR_ALREADY_IN_USE, "Already in use error", 2 );
MBED_WARNING1(MBED_ERROR_UNSUPPORTED, "Not supported error", 3 );
MBED_WARNING1(MBED_ERROR_ACCESS_DENIED, "Access denied error", 4 );
MBED_WARNING1(MBED_ERROR_ITEM_NOT_FOUND, "Not found error", 5 );
int error = 0;

View File

@ -57,13 +57,13 @@ int ReadOnlyBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
int ReadOnlyBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLOCK_DEVICE, MBED_ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::program() not allowed", addr);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_BLOCK_DEVICE, MBED_ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::program() not allowed", addr);
return MBED_ERROR_WRITE_PROTECTED;
}
int ReadOnlyBlockDevice::erase(bd_addr_t addr, bd_size_t size)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLOCK_DEVICE, MBED_ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::erase() not allowed", addr);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_BLOCK_DEVICE, MBED_ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::erase() not allowed", addr);
return MBED_ERROR_WRITE_PROTECTED;
}

View File

@ -29,7 +29,7 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
}
map++;
}
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
}
uint32_t pinmap_merge(uint32_t a, uint32_t b) {
@ -44,7 +44,7 @@ uint32_t pinmap_merge(uint32_t a, uint32_t b) {
return a;
// mis-match error case
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
return (uint32_t)NC;
}
@ -64,7 +64,7 @@ uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
return (uint32_t)NC;
peripheral = pinmap_find_peripheral(pin, map);
if ((uint32_t)NC == peripheral) // no mapping available
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
return peripheral;
}
@ -84,6 +84,6 @@ uint32_t pinmap_function(PinName pin, const PinMap* map) {
return (uint32_t)NC;
function = pinmap_find_function(pin, map);
if ((uint32_t)NC == function) // no mapping available
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
return function;
}

View File

@ -161,7 +161,7 @@ void sleep_manager_lock_deep_sleep_internal(void)
core_util_critical_section_enter();
if (deep_sleep_lock == USHRT_MAX) {
core_util_critical_section_exit();
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
}
core_util_atomic_incr_u16(&deep_sleep_lock, 1);
core_util_critical_section_exit();
@ -172,7 +172,7 @@ void sleep_manager_unlock_deep_sleep_internal(void)
core_util_critical_section_enter();
if (deep_sleep_lock == 0) {
core_util_critical_section_exit();
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_HAL, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
}
core_util_atomic_decr_u16(&deep_sleep_lock, 1);
core_util_critical_section_exit();

View File

@ -69,7 +69,7 @@ public:
sleep_manager_lock_deep_sleep();
}
if (0 == count) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", count);
}
}
@ -83,7 +83,7 @@ public:
}
if (count == USHRT_MAX) {
core_util_critical_section_exit();
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", count);
}
}
};

View File

@ -29,7 +29,7 @@ Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
if (_file) {
mbed_set_unbuffered_stream(_file);
} else {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OPEN_FAILED), "Stream obj failure", _file);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OPEN_FAILED), "Stream obj failure", _file);
}
}

View File

@ -78,7 +78,7 @@ WEAK void error(const char* format, ...) {
va_list arg;
va_start(arg, format);
mbed_error_vfprintf(format, arg);
MBED_ERROR(MBED_ERROR_UNKNOWN, "Fatal Run-time Error", 0);
MBED_ERROR(MBED_ERROR_UNKNOWN, "Fatal Run-time Error");
va_end(arg);
#endif
exit(1);

View File

@ -127,47 +127,55 @@ typedef int mbed_error_status_t;
/**
* Macro for setting a system error. This macro will log the error, prints the error report and return to the caller. Its a wrapper for calling mbed_error API.
* Macros for setting a system warning. These macros will log the error, Its a wrapper for calling mbed_warning API.
* There are 2 versions of this macro. MBED_WARNING takes status and message. MBED_WARNING1 takes an additional context specific argument
* @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
* @param error_msg The error message to be printed out to STDIO/Serial.
* @param error_value Value associated with the error status. This would depend on error code/error scenario.
*
* @code
*
* MBED_ERROR( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read", size_val )
* MBED_WARNING( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read" )
* MBED_WARNING1( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read", size_val )
*
* @endcode
* @note The macro calls mbed_error API with filename and line number info without caller explicitly passing them.
* Since this macro is a wrapper for mbed_error API callers should process the return value from this macro which is the return value from calling mbed_error API.
* @note The macro calls mbed_warning API with filename and line number info without caller explicitly passing them.
* Since this macro is a wrapper for mbed_warning API callers should process the return value from this macro which is the return value from calling mbed_error API.
*
*/
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
#define MBED_WARNING( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
#define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ )
#define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
#else
#define MBED_WARNING( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
#define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 )
#define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
#endif
/**
* Macro for setting a fatal system error. This macro will log the error, prints the error report and halts the system. Its a wrapper for calling mbed_error API
* Macros for setting a fatal system error. These macros will log the error, prints the error report and halts the system. Its a wrapper for calling mbed_error API.
* There are 2 versions of this macro. MBED_ERROR takes status and message. MBED_ERROR1 takes an additional context specific argument
* @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
* @param error_msg The error message to be printed out to STDIO/Serial.
* @param error_value Value associated with the error status. This would depend on error code/error scenario.
* @param error_value Value associated with the error status. This would depend on error code/error scenario. Only available with MBED_ERROR1
* @return 0 or MBED_SUCCESS.
* MBED_ERROR_INVALID_ARGUMENT if called with invalid error status/codes
*
* @code
*
* MBED_ERROR( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex", &my_mutex )
* MBED_ERROR( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex" )
* MBED_ERROR1( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex", &my_mutex )
*
* @endcode
* @note The macro calls mbed_error API with filename and line number info without caller explicitly passing them.
* Since this macro is a wrapper for mbed_error API callers should process the return value from this macro which is the return value from calling mbed_error API.
* Since this macro is a wrapper for mbed_error API callers should process the return value from this macro which is the return value from calling mbed_error API.
*
*/
#ifdef MBED_CONF_ERROR_FILENAME_CAPTURE_ENABLED
#define MBED_ERROR( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
#define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ )
#define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, (const char *)MBED_FILENAME, __LINE__ )
#else
#define MBED_ERROR( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
#define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 )
#define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 )
#endif
//Error Type definition
@ -901,7 +909,7 @@ void error(const char* format, ...);
typedef void (*mbed_error_hook_t)(const mbed_error_ctx *error_ctx);
/**
* Call this function to set a system error/warning. This function will log the error status with the context info, prints the error report and return to caller.
* Call this function to set a system error/warning. This function will log the error status with the context info and return to caller.
*
* @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
* @param error_msg The error message to be printed out to STDIO/Serial.
@ -943,7 +951,7 @@ mbed_error_status_t mbed_get_last_error(void);
int mbed_get_error_count(void);
/**
* Call this function to set a fatal system error and halt the system. This function will log the fatal error with the context info and prints the error report.
* Call this function to set a fatal system error and halt the system. This function will log the fatal error with the context info and prints the error report and halts the system.
*
* @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values).
* @param error_msg The error message to be printed out to STDIO/Serial.
@ -986,7 +994,7 @@ mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *err
mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t custom_error_hook);
/**
* Reads the first error context information logged.
* Reads the first error context information captured.
* @param error_info This is the mbed_error_context info captured as part of the first mbed_error call. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
* @return 0 or MBED_SUCCESS on success.
* MBED_ERROR_INVALID_ARGUMENT in case of invalid index
@ -995,7 +1003,7 @@ mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t custom_error_hook);
mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info);
/**
* Reads the last error context information logged.
* Reads the last error context information captured.
* @param error_info This is the mbed_error_context info captured as part of the last mbed_error call. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
* @return 0 or MBED_ERROR_SUCCESS on success.
* MBED_ERROR_INVALID_ARGUMENT in case of invalid index
@ -1004,7 +1012,7 @@ mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info);
mbed_error_status_t mbed_get_last_error_info(mbed_error_ctx *error_info);
/**
* Clears all the last error, error count and all entries in the error log.
* Clears the last error, first error, error count and all entries in the error history.
* @return 0 or MBED_SUCCESS on success.
*
*/
@ -1021,19 +1029,19 @@ mbed_error_status_t mbed_clear_all_errors(void);
mbed_error_status_t mbed_make_error(mbed_error_type_t error_type, mbed_module_type_t module, mbed_error_code_t error_code);
/**
* Returns the current number of entries in the error log, if there has been more than max number of errors logged the number returned will be max depth of error log.
* @return Current number of entries in the error log.
* Returns the current number of entries in the error history, if there has been more than max number of errors logged the number returned will be max depth of error history.
* @return Current number of entries in the error history.
*
*/
int mbed_get_error_hist_count(void);
/**
* Reads the error context information for a specific error log specified by the index.
* Reads the error context information for a specific error from error history, specified by the index.
*
* @param index index of the error context entry in the log to be retrieved.\n
* The number of entries in the error log depth is configured during build and the max index depends on max depth of error log.\n
* index = 0 points to the oldest entry in the log, and index = (max log depth - 1) points to the latest entry in the error log.\n
* @param error_info This is the mbed_error_context info captured as part of the log. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
* @param index index of the error context entry in the history to be retrieved.\n
* The number of entries in the error history is configured during build and the max index depends on max depth of error history.\n
* index = 0 points to the oldest entry in the history, and index = (max history depth - 1) points to the latest entry in the error history.\n
* @param error_info This is the mbed_error_context info captured as part of the error history. The caller should pass a pointer to mbed_error_context struct allocated by the caller.
* @return 0 or MBED_SUCCESS on success.
* MBED_ERROR_INVALID_ARGUMENT in case of invalid index
*
@ -1041,7 +1049,7 @@ int mbed_get_error_hist_count(void);
mbed_error_status_t mbed_get_error_hist_info(int index, mbed_error_ctx *error_info);
/**
* Saves the error log information to a file
* Saves the error history information to a file
*
* @param path path to the file in the filesystem
* @return 0 or MBED_ERROR_SUCCESS on success.

View File

@ -538,7 +538,7 @@ extern "C" int PREFIX(_write)(FILEHANDLE fh, const unsigned char *buffer, unsign
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED && defined(MBED_CONF_RTOS_PRESENT)
if (core_util_is_isr_active() || !core_util_are_interrupts_enabled()) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PROHIBITED_IN_ISR_CONTEXT), "Error - writing to a file in an ISR or critical section\r\n", fh);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PROHIBITED_IN_ISR_CONTEXT), "Error - writing to a file in an ISR or critical section\r\n", fh);
}
#endif
@ -646,7 +646,7 @@ extern "C" int PREFIX(_read)(FILEHANDLE fh, unsigned char *buffer, unsigned int
#if defined(MBED_TRAP_ERRORS_ENABLED) && MBED_TRAP_ERRORS_ENABLED && defined(MBED_CONF_RTOS_PRESENT)
if (core_util_is_isr_active() || !core_util_are_interrupts_enabled()) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PROHIBITED_IN_ISR_CONTEXT), "Error - reading from a file in an ISR or critical section\r\n", fh);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_PROHIBITED_IN_ISR_CONTEXT), "Error - reading from a file in an ISR or critical section\r\n", fh);
}
#endif
@ -1088,7 +1088,7 @@ extern "C" int statvfs(const char *path, struct statvfs *buf) {
#include "mbed_error.h"
namespace __gnu_cxx {
void __verbose_terminate_handler() {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CLIB_EXCEPTION),"Exception", 0);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_CLIB_EXCEPTION),"Exception", 0);
}
}
extern "C" WEAK void __cxa_pure_virtual(void);
@ -1387,7 +1387,7 @@ void *operator new(std::size_t count)
{
void *buffer = malloc_wrapper(count, MBED_CALLER_ADDR());
if (NULL == buffer) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
}
return buffer;
}
@ -1431,7 +1431,7 @@ void *operator new(std::size_t count)
{
void *buffer = malloc_wrapper(_REENT, count, MBED_CALLER_ADDR());
if (NULL == buffer) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
}
return buffer;
}
@ -1440,7 +1440,7 @@ void *operator new[](std::size_t count)
{
void *buffer = malloc_wrapper(_REENT, count, MBED_CALLER_ADDR());
if (NULL == buffer) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
}
return buffer;
}
@ -1471,7 +1471,7 @@ void *operator new(std::size_t count)
{
void *buffer = malloc(count);
if (NULL == buffer) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new out of memory\r\n", count);
}
return buffer;
}
@ -1480,7 +1480,7 @@ void *operator new[](std::size_t count)
{
void *buffer = malloc(count);
if (NULL == buffer) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new[] out of memory\r\n", count);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Operator new[] out of memory\r\n", count);
}
return buffer;
}

View File

@ -323,7 +323,7 @@ void mbed_start_main(void)
_main_thread_attr.name = "main_thread";
osThreadId_t result = osThreadNew((osThreadFunc_t)pre_main, NULL, &_main_thread_attr);
if ((void *)result == NULL) {
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Pre main thread not created", &_main_thread_attr);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_INITIALIZATION_FAILED), "Pre main thread not created", &_main_thread_attr);
}
osKernelStart();

View File

@ -47,27 +47,27 @@ __NO_RETURN uint32_t osRtxErrorNotify (uint32_t code, void *object_id)
case osRtxErrorStackUnderflow:
// Stack underflow detected for thread (thread_id=object_id)
// Note: "overflow" is printed instead of "underflow" due to end user familiarity with overflow errors
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_STACK_OVERFLOW), "CMSIS-RTOS error: Stack overflow", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_STACK_OVERFLOW), "CMSIS-RTOS error: Stack overflow", code);
break;
case osRtxErrorISRQueueOverflow:
// ISR Queue overflow detected when inserting object (object_id)
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_ISR_QUEUE_OVERFLOW), "CMSIS-RTOS error: ISR Queue overflow", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_ISR_QUEUE_OVERFLOW), "CMSIS-RTOS error: ISR Queue overflow", code);
break;
case osRtxErrorTimerQueueOverflow:
// User Timer Callback Queue overflow detected for timer (timer_id=object_id)
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_TIMER_QUEUE_OVERFLOW), "CMSIS-RTOS error: User Timer Callback Queue overflow", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_TIMER_QUEUE_OVERFLOW), "CMSIS-RTOS error: User Timer Callback Queue overflow", code);
break;
case osRtxErrorClibSpace:
// Standard C/C++ library libspace not available: increase OS_THREAD_LIBSPACE_NUM
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_SPACE_UNAVAILABLE), "CMSIS-RTOS error: STD C/C++ library libspace not available", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_SPACE_UNAVAILABLE), "CMSIS-RTOS error: STD C/C++ library libspace not available", code);
break;
case osRtxErrorClibMutex:
// Standard C/C++ library mutex initialization failed
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_MUTEX_INIT_FAILURE), "CMSIS-RTOS error: STD C/C++ library mutex initialization failed", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_CLIB_MUTEX_INIT_FAILURE), "CMSIS-RTOS error: STD C/C++ library mutex initialization failed", code);
break;
default:
//Unknown error flagged from kernel
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_UNKNOWN), "CMSIS-RTOS error: Unknown", code);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_KERNEL, MBED_ERROR_CODE_UNKNOWN), "CMSIS-RTOS error: Unknown", code);
break;
}
@ -99,27 +99,27 @@ static const char* error_msg(int32_t status)
void EvrRtxKernelError (int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT), error_msg(status), status);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT), error_msg(status), status);
}
void EvrRtxThreadError (osThreadId_t thread_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_THREAD_EVENT), error_msg(status), thread_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_THREAD_EVENT), error_msg(status), thread_id);
}
void EvrRtxTimerError (osTimerId_t timer_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_TIMER_EVENT), error_msg(status), timer_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_TIMER_EVENT), error_msg(status), timer_id);
}
void EvrRtxEventFlagsError (osEventFlagsId_t ef_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT), error_msg(status), ef_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_EVENT_FLAGS_EVENT), error_msg(status), ef_id);
}
void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MUTEX_EVENT), error_msg(status), mutex_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MUTEX_EVENT), error_msg(status), mutex_id);
}
void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
@ -129,17 +129,17 @@ void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
return;
}
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT), error_msg(status), semaphore_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_SEMAPHORE_EVENT), error_msg(status), semaphore_id);
}
void EvrRtxMemoryPoolError (osMemoryPoolId_t mp_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT), error_msg(status), mp_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MEMORY_POOL_EVENT), error_msg(status), mp_id);
}
void EvrRtxMessageQueueError (osMessageQueueId_t mq_id, int32_t status)
{
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT), error_msg(status), mq_id);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_RTOS_MESSAGE_QUEUE_EVENT), error_msg(status), mq_id);
}
#endif

View File

@ -78,13 +78,13 @@ void Thread::constructor(Callback<void()> task,
switch (start(task)) {
case osErrorResource:
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_RESOURCES), "OS ran out of threads!\n", task);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_RESOURCES), "OS ran out of threads!\n", task);
break;
case osErrorParameter:
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_ALREADY_IN_USE), "Thread already running!\n", task);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_ALREADY_IN_USE), "Thread already running!\n", task);
break;
case osErrorNoMemory:
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Error allocating the stack memory\n", task);
MBED_ERROR1(MBED_MAKE_ERROR(MBED_MODULE_PLATFORM, MBED_ERROR_CODE_OUT_OF_MEMORY), "Error allocating the stack memory\n", task);
default:
break;
}