Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
mbed_error.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 #ifndef MBED_ERROR_H 00018 #define MBED_ERROR_H 00019 00020 #include <stdbool.h> 00021 #include "platform/mbed_retarget.h" 00022 #include "platform/mbed_toolchain.h" 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 /** \addtogroup platform-public-api */ 00029 /** @{*/ 00030 00031 /** 00032 * \defgroup platform_error Error functions 00033 * @{ 00034 */ 00035 00036 /** Define this macro to include filenames in error context. For release builds, do not include filename to save memory. 00037 * MBED_PLATFORM_CONF_ERROR_FILENAME_CAPTURE_ENABLED 00038 */ 00039 00040 /** Define this macro to enable error history 00041 * MBED_PLATFORM_CONF_ERROR_HIST_ENABLED 00042 */ 00043 00044 #ifndef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 00045 #define MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 16 00046 #else //MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 00047 #if MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN > 64 00048 //We have to limit this to 64 bytes since we use mbed_error_printf for error reporting 00049 //and mbed_error_vprintf uses 128bytes internal buffer which may not be sufficient for anything 00050 //longer that 64 bytes with the current implementation. 00051 #error "Unsupported error filename buffer length detected, max supported length is 64 chars. Please change MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN or max-error-filename-len in configuration." 00052 #endif 00053 #endif 00054 00055 #define MBED_ERROR_STATUS_CODE_MASK (0x0000FFFF) 00056 #define MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK (0x0000FFFF) 00057 #define MBED_ERROR_STATUS_CODE_POS (0) 00058 #define MBED_ERROR_STATUS_CODE_FIELD_SIZE (16) 00059 00060 #define MBED_ERROR_STATUS_MODULE_MASK (0x00FF0000) 00061 #define MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK (0x000000FF) 00062 #define MBED_ERROR_STATUS_MODULE_POS (16) 00063 #define MBED_ERROR_STATUS_MODULE_FIELD_SIZE (8) 00064 00065 #define MBED_ERROR_STATUS_TYPE_MASK (0x60000000) 00066 #define MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK (0x00000003) 00067 #define MBED_ERROR_STATUS_TYPE_POS (29) 00068 #define MBED_ERROR_STATUS_TYPE_FIELD_SIZE (2) 00069 00070 /* mbed_error_status_t Status Encoding */ 00071 //|31(1 bit) Always Negative|30-29(2 bits) |28-24 | 23-16(8 bits) | 15-0(16 bits) | 00072 //|-1 |TYPE |(unused/reserved) | MODULE TYPE | ERROR CODE | 00073 00074 #define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \ 00075 ((0x80000000) | \ 00076 ((mbed_error_status_t) (error_code & MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_CODE_POS) | \ 00077 ((mbed_error_status_t) (module & MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_MODULE_POS) | \ 00078 ((mbed_error_status_t) (type & MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_TYPE_POS)) 00079 00080 #define MBED_GET_ERROR_TYPE( error_status ) ((error_status & MBED_ERROR_STATUS_TYPE_MASK) >> MBED_ERROR_STATUS_TYPE_POS) 00081 #define MBED_GET_ERROR_MODULE( error_status ) ((error_status & MBED_ERROR_STATUS_MODULE_MASK) >> MBED_ERROR_STATUS_MODULE_POS) 00082 #define MBED_GET_ERROR_CODE( error_status ) (int)((MBED_GET_ERROR_TYPE( error_status ) == MBED_ERROR_TYPE_POSIX)?(-error_status):((error_status & MBED_ERROR_STATUS_CODE_MASK) >> MBED_ERROR_STATUS_CODE_POS)) 00083 00084 /** mbed_error_status_t description 00085 * 00086 * mbed_error_status_t type represents the error status values under MbedOS. mbed_error_status_t values are signed integers and always be negative.\n 00087 * Internally its encoded as below with bit-fields representing error type, module and error code:\n\n 00088 * mbed_error_status_t Status Encoding:\n 00089 * 00090 \verbatim 00091 | 31 Always Negative | 30-29(2 bits) | 28-24 | 23-16(8 bits) | 15-0(16 bits) | 00092 | -1 | TYPE | (unused/reserved) | MODULE TYPE | ERROR CODE | 00093 \endverbatim 00094 * 00095 * The error status value range for each error type is as follows:\n 00096 * POSIX Error Status-es - 0xFFFFFFFF to 0xFFFFFF01(-1 -255) - This corresponds to POSIX error codes represented as negative.\n 00097 * System Error Status-es - 0x80XX0100 to 0x80XX0FFF - This corresponds to System error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n 00098 * Custom Error Status-es - 0xA0XX1000 to 0xA0XXFFFF - This corresponds to Custom error codes range(all values are negative). Bits 23-16 will be module type(marked with XX)\n\n 00099 * 00100 * The ERROR CODE(values encoded into ERROR CODE bit-field in mbed_error_status_t) value range for each error type is also separated as below:\n 00101 * POSIX Error Codes - 1 to 255.\n 00102 * System Error Codes - 256 to 4095.\n 00103 * Custom Error Codes - 4096 to 65535.\n 00104 * 00105 * @note POSIX error codes are always encoded as negative of their actual value. For example, EPERM is encoded as -EPERM. 00106 * And, the MODULE TYPE for POSIX error codes are always encoded as MBED_MODULE_UNKNOWN.\n 00107 * This is to enable easy injection of POSIX error codes into MbedOS error handling system without altering the actual POSIX error values.\n 00108 * Accordingly, POSIX error codes are represented as -1 to -255 under MbedOS error status representation. 00109 */ 00110 typedef int mbed_error_status_t; 00111 00112 /** 00113 * Macro for defining a POSIX error status. This macro is mainly used to define POSIX error values in mbed_error_code_t enumeration. 00114 * @param error_name Name of the error without the ERROR_ prefix 00115 * @param error_code Error code value to be used, must be between 1 and 255(inclusive). 00116 * 00117 */ 00118 #define MBED_DEFINE_POSIX_ERROR( error_name, error_code ) \ 00119 MBED_ERROR_CODE_##error_name = error_code, \ 00120 MBED_ERROR_##error_name = -(MBED_POSIX_ERROR_BASE + error_code) 00121 00122 /** 00123 * Macro for defining a System error status. This macro is used to define System error values in mbed_error_code_t enumeration. 00124 * @param error_name Name of the error without the ERROR_ prefix 00125 * @param error_code Error code value to be used, must be between 256 and 4096(inclusive). 00126 * 00127 */ 00128 #define MBED_DEFINE_SYSTEM_ERROR( error_name, error_code ) \ 00129 MBED_ERROR_CODE_##error_name = MBED_SYSTEM_ERROR_BASE + error_code, \ 00130 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 00131 00132 /** 00133 * Macro for defining a Custom error status. This macro is used to define custom error values in mbed_error_code_t enumeration. 00134 * @param error_name Name of the error without the ERROR_ prefix 00135 * @param error_code Error code value to be used, must be between 4097 and 65535(inclusive). 00136 * 00137 */ 00138 #define MBED_DEFINE_CUSTOM_ERROR( error_name, error_code ) \ 00139 MBED_ERROR_CODE_##error_name = MBED_CUSTOM_ERROR_BASE + error_code, \ 00140 MBED_ERROR_##error_name = MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, MBED_ERROR_CODE_##error_name) 00141 00142 00143 /** 00144 * Macros for setting a system warning. These macros will log the error, Its a wrapper for calling mbed_warning API. 00145 * There are 2 versions of this macro. MBED_WARNING takes status and message. MBED_WARNING1 takes an additional context specific argument 00146 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values). 00147 * @param error_msg The error message to be printed out to STDIO/Serial. 00148 * @param error_value Value associated with the error status. This would depend on error code/error scenario. 00149 * 00150 * @code 00151 * 00152 * MBED_WARNING( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read" ) 00153 * MBED_WARNING1( ERROR_INVALID_SIZE, "MyDriver: Invalid size in read", size_val ) 00154 * 00155 * @endcode 00156 * @note The macro calls mbed_warning API with filename and line number info without caller explicitly passing them. 00157 * 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. 00158 * 00159 */ 00160 #ifdef NDEBUG 00161 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 00162 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)NULL, (uint32_t)0, NULL, 0 ) 00163 #else //NDEBUG 00164 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 00165 #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__ ) 00166 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 00167 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 00168 #define MBED_WARNING1( error_status, error_msg, error_value ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 00169 #define MBED_WARNING( error_status, error_msg ) mbed_warning( error_status, (const char *)error_msg, (uint32_t)0, NULL, 0 ) 00170 #endif 00171 #endif 00172 00173 /** 00174 * 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. 00175 * There are 2 versions of this macro. MBED_ERROR takes status and message. MBED_ERROR1 takes an additional context specific argument 00176 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values). 00177 * @param error_msg The error message to be printed out to STDIO/Serial. 00178 * @param error_value Value associated with the error status. This would depend on error code/error scenario. Only available with MBED_ERROR1 00179 * @return Does not return 00180 * 00181 * @code 00182 * 00183 * MBED_ERROR( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex" ) 00184 * MBED_ERROR1( MBED_ERROR_MUTEX_LOCK_FAILED, "MyDriver: Can't lock driver Mutex", &my_mutex ) 00185 * 00186 * @endcode 00187 * @note The macro calls mbed_error API with filename and line number info without caller explicitly passing them. 00188 * 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. 00189 * 00190 */ 00191 #ifdef NDEBUG 00192 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)NULL, (uint32_t)error_value, NULL, 0 ) 00193 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)NULL, (uint32_t)0 , NULL, 0 ) 00194 #else //NDEBUG 00195 #if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 00196 #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__ ) 00197 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , (const char *)MBED_FILENAME, __LINE__ ) 00198 #else //MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED 00199 #define MBED_ERROR1( error_status, error_msg, error_value ) mbed_error( error_status, (const char *)error_msg, (uint32_t)error_value, NULL, 0 ) 00200 #define MBED_ERROR( error_status, error_msg ) mbed_error( error_status, (const char *)error_msg, (uint32_t)0 , NULL, 0 ) 00201 #endif 00202 #endif 00203 00204 //Error Type definition 00205 /** mbed_error_type_t definition 00206 * @note 00207 * This enumeration defines the Error types supported. The value of these enum values will be encoded into mbed_error_status_t TYPE field.\n 00208 * See mbed_error_status_t description for more info.\n 00209 * MBED_ERROR_TYPE_SYSTEM - Used to indicate that the error status is of System defined Error type.\n 00210 * MBED_ERROR_TYPE_CUSTOM - Used to indicate that the error status is of Custom defined Error type.\n 00211 * MBED_ERROR_TYPE_POSIX - Used to indicate that the error status is of POSIX error type.\n 00212 * 00213 */ 00214 typedef enum _mbed_error_type_t { 00215 MBED_ERROR_TYPE_SYSTEM = 0, 00216 MBED_ERROR_TYPE_CUSTOM = 1, 00217 //2 is reserved 00218 //Use 3 for POSIX because we are mapping -1 to -255 to POSIX error codes 00219 //and thus we must use 3 to match the type bits in error status representation which are from 0xFFFFFFFF to 0xFFFFFF00 00220 MBED_ERROR_TYPE_POSIX = 3 00221 } mbed_error_type_t; 00222 00223 //Module type/id definitions 00224 /** mbed_module_type_t definition 00225 * @note 00226 * This enumeration defines the module types. The value of these enum values will be encoded into mbed_error_status_t MODULE field.\n\n 00227 * See mbed_error_status_t description for more info.\n 00228 * MBED_MODULE_UNKNOWN - This module type can be used if caller of the mbed_error/mbed_warning doesn't know who is the actual originator of the error.\n 00229 * Other module values can be used to provide more info on who/where the error originated from.\n\n 00230 * For example, if I2C driver is the component originating the error you can use MBED_MODULE_DRIVER_I2C to provide more info.\n 00231 * Its used in call to MBED_MAKE_ERROR/MBED_MAKE_SYSTEM_ERROR/MBED_MAKE_CUSTOM_ERROR macros.\n 00232 * 00233 * @code 00234 * Example: mbed_error_status_t i2c_driver_error = MBED_MAKE_ERROR( MBED_MODULE_DRIVER_I2C, MBED_ERROR_CONFIG_UNSUPPORTED ); 00235 * @endcode 00236 * 00237 * @note 00238 * \n Below are the module code mappings:\n 00239 \verbatim 00240 MBED_MODULE_APPLICATION 0 Application 00241 MBED_MODULE_PLATFORM 1 Platform 00242 MBED_MODULE_KERNEL 2 RTX Kernel 00243 MBED_MODULE_NETWORK_STACK 3 Network stack 00244 MBED_MODULE_HAL 4 HAL - Hardware Abstraction Layer 00245 MBED_MODULE_MEMORY_SUBSYSTEM 5 Memory Subsystem 00246 MBED_MODULE_FILESYSTEM 6 Filesystem 00247 MBED_MODULE_BLOCK_DEVICE 7 Block device 00248 MBED_MODULE_DRIVER 8 Driver 00249 MBED_MODULE_DRIVER_SERIAL 9 Serial Driver 00250 MBED_MODULE_DRIVER_RTC 10 RTC Driver 00251 MBED_MODULE_DRIVER_I2C 11 I2C Driver 00252 MBED_MODULE_DRIVER_SPI 12 SPI Driver 00253 MBED_MODULE_DRIVER_GPIO 13 GPIO Driver 00254 MBED_MODULE_DRIVER_ANALOG 14 Analog Driver 00255 MBED_MODULE_DRIVER_DIGITAL 15 DigitalIO Driver 00256 MBED_MODULE_DRIVER_CAN 16 CAN Driver 00257 MBED_MODULE_DRIVER_ETHERNET 17 Ethernet Driver 00258 MBED_MODULE_DRIVER_CRC 18 CRC Module 00259 MBED_MODULE_DRIVER_PWM 19 PWM Driver 00260 MBED_MODULE_DRIVER_QSPI 20 QSPI Driver 00261 MBED_MODULE_DRIVER_USB 21 USB Driver 00262 MBED_MODULE_TARGET_SDK 22 SDK 00263 MBED_MODULE_BLE 23 BLE 00264 MBED_MODULE_NETWORK_STATS 24 Network Statistics 00265 00266 MBED_MODULE_UNKNOWN 255 Unknown module 00267 \endverbatim 00268 * 00269 */ 00270 typedef enum _mbed_module_type { 00271 MBED_MODULE_APPLICATION = 0, 00272 MBED_MODULE_PLATFORM, 00273 MBED_MODULE_KERNEL, 00274 MBED_MODULE_NETWORK_STACK, 00275 MBED_MODULE_HAL, 00276 MBED_MODULE_MEMORY_SUBSYSTEM, 00277 MBED_MODULE_FILESYSTEM, 00278 MBED_MODULE_BLOCK_DEVICE, 00279 MBED_MODULE_DRIVER, 00280 MBED_MODULE_DRIVER_SERIAL, 00281 MBED_MODULE_DRIVER_RTC, 00282 MBED_MODULE_DRIVER_I2C, 00283 MBED_MODULE_DRIVER_SPI, 00284 MBED_MODULE_DRIVER_GPIO, 00285 MBED_MODULE_DRIVER_ANALOG, 00286 MBED_MODULE_DRIVER_DIGITAL, 00287 MBED_MODULE_DRIVER_CAN, 00288 MBED_MODULE_DRIVER_ETHERNET, 00289 MBED_MODULE_DRIVER_CRC, 00290 MBED_MODULE_DRIVER_PWM, 00291 MBED_MODULE_DRIVER_QSPI, 00292 MBED_MODULE_DRIVER_USB, 00293 MBED_MODULE_DRIVER_WATCHDOG, 00294 MBED_MODULE_TARGET_SDK, 00295 MBED_MODULE_BLE, 00296 MBED_MODULE_NETWORK_STATS, 00297 /* Add More entities here as required */ 00298 00299 MBED_MODULE_UNKNOWN = 255, 00300 MBED_MODULE_MAX = MBED_MODULE_UNKNOWN 00301 } mbed_module_type_t; 00302 00303 //Use MBED_SUCCESS(=0) or any positive number for successful returns 00304 #define MBED_SUCCESS 0 00305 00306 #define MBED_POSIX_ERROR_BASE 0 00307 #define MBED_SYSTEM_ERROR_BASE 256 00308 #define MBED_CUSTOM_ERROR_BASE 4096 00309 00310 //Error Code definitions 00311 /** mbed_error_code_t definition 00312 * 00313 * mbed_error_code_t enumeration defines the Error codes and Error status values for MBED_MODULE_UNKNOWN.\n 00314 * It defines all of POSIX Error Codes/Statuses and Mbed System Error Codes/Statuses.\n\n 00315 * 00316 * @note 00317 * POSIX Error codes are defined using the macro MBED_DEFINE_POSIX_ERROR\n 00318 * For example MBED_DEFINE_POSIX_ERROR( EPERM, EPERM ). This effectively defines the following values:\n 00319 * ERROR_CODE_EPERM = EPERM\n 00320 * ERROR_EPERM = -EPERM\n 00321 * 00322 * POSIX Error codes are defined using the macro MBED_DEFINE_POSIX_ERROR\n 00323 * For example MBED_DEFINE_POSIX_ERROR( EPERM, EPERM ). This macro defines the following values:\n 00324 * ERROR_CODE_EPERM = MBED_POSIX_ERROR_BASE+EPERM\n 00325 * ERROR_EPERM = -(MBED_POSIX_ERROR_BASE+EPERM)\n 00326 * Its effectively equivalent to:\n 00327 * ERROR_CODE_EPERM = 1\n 00328 * ERROR_EPERM = -1\n 00329 * All POSIX error codes currently supported by MbedOS(defined in mbed_retarget.h) are defined using the MBED_DEFINE_POSIX_ERROR macro.\n\n 00330 * Below are the POSIX error codes and the description:\n 00331 * \verbatim 00332 EPERM 1 Operation not permitted 00333 ENOENT 2 No such file or directory 00334 ESRCH 3 No such process 00335 EINTR 4 Interrupted system call 00336 EIO 5 I/O error 00337 ENXIO 6 No such device or address 00338 E2BIG 7 Argument list too long 00339 ENOEXEC 8 Exec format error 00340 EBADF 9 Bad file number 00341 ECHILD 10 No child processes 00342 EAGAIN 11 Try again 00343 ENOMEM 12 Out of memory 00344 EACCES 13 Permission denied 00345 EFAULT 14 Bad address 00346 ENOTBLK 15 Block device required 00347 EBUSY 16 Device or resource busy 00348 EEXIST 17 File exists 00349 EXDEV 18 Cross-device link 00350 ENODEV 19 No such device 00351 ENOTDIR 20 Not a directory 00352 EISDIR 21 Is a directory 00353 EINVAL 22 Invalid argument 00354 ENFILE 23 File table overflow 00355 EMFILE 24 Too many open files 00356 ENOTTY 25 Not a typewriter 00357 ETXTBSY 26 Text file busy 00358 EFBIG 27 File too large 00359 ENOSPC 28 No space left on device 00360 ESPIPE 29 Illegal seek 00361 EROFS 30 Read-only file system 00362 EMLINK 31 Too many links 00363 EPIPE 32 Broken pipe 00364 EDOM 33 Math argument out of domain of func 00365 ERANGE 34 Math result not representable 00366 EDEADLK 35 Resource deadlock would occur 00367 ENAMETOOLONG 36 File name too long 00368 ENOLCK 37 No record locks available 00369 ENOSYS 38 Function not implemented 00370 ENOTEMPTY 39 Directory not empty 00371 ELOOP 40 Too many symbolic links encountered 00372 EWOULDBLOCK EAGAIN Operation would block 00373 ENOMSG 42 No message of desired type 00374 EIDRM 43 Identifier removed 00375 ECHRNG 44 Channel number out of range 00376 EL2NSYNC 45 Level 2 not synchronized 00377 EL3HLT 46 Level 3 halted 00378 EL3RST 47 Level 3 reset 00379 ELNRNG 48 Link number out of range 00380 EUNATCH 49 Protocol driver not attached 00381 ENOCSI 50 No CSI structure available 00382 EL2HLT 51 Level 2 halted 00383 EBADE 52 Invalid exchange 00384 EBADR 53 Invalid request descriptor 00385 EXFULL 54 Exchange full 00386 ENOANO 55 No anode 00387 EBADRQC 56 Invalid request code 00388 EBADSLT 57 Invalid slot 00389 EDEADLOCK EDEADLK Resource deadlock would occur 00390 EBFONT 59 Bad font file format 00391 ENOSTR 60 Device not a stream 00392 ENODATA 61 No data available 00393 ETIME 62 Timer expired 00394 ENOSR 63 Out of streams resources 00395 ENONET 64 Machine is not on the network 00396 ENOPKG 65 Package not installed 00397 EREMOTE 66 Object is remote 00398 ENOLINK 67 Link has been severed 00399 EADV 68 Advertise error 00400 ESRMNT 69 Srmount error 00401 ECOMM 70 Communication error on send 00402 EPROTO 71 Protocol error 00403 EMULTIHOP 72 Multihop attempted 00404 EDOTDOT 73 RFS specific error 00405 EBADMSG 74 Not a data message 00406 EOVERFLOW 75 Value too large for defined data type 00407 ENOTUNIQ 76 Name not unique on network 00408 EBADFD 77 File descriptor in bad state 00409 EREMCHG 78 Remote address changed 00410 ELIBACC 79 Can not access a needed shared library 00411 ELIBBAD 80 Accessing a corrupted shared library 00412 ELIBSCN 81 .lib section in a.out corrupted 00413 ELIBMAX 82 Attempting to link in too many shared libraries 00414 ELIBEXEC 83 Cannot exec a shared library directly 00415 EILSEQ 84 Illegal byte sequence 00416 ERESTART 85 Interrupted system call should be restarted 00417 ESTRPIPE 86 Streams pipe error 00418 EUSERS 87 Too many users 00419 ENOTSOCK 88 Socket operation on non-socket 00420 EDESTADDRREQ 89 Destination address required 00421 EMSGSIZE 90 Message too long 00422 EPROTOTYPE 91 Protocol wrong type for socket 00423 ENOPROTOOPT 92 Protocol not available 00424 EPROTONOSUPPORT 93 Protocol not supported 00425 ESOCKTNOSUPPORT 94 Socket type not supported 00426 EOPNOTSUPP 95 Operation not supported on transport endpoint 00427 EPFNOSUPPORT 96 Protocol family not supported 00428 EAFNOSUPPORT 97 Address family not supported by protocol 00429 EADDRINUSE 98 Address already in use 00430 EADDRNOTAVAIL 99 Cannot assign requested address 00431 ENETDOWN 100 Network is down 00432 ENETUNREACH 101 Network is unreachable 00433 ENETRESET 102 Network dropped connection because of reset 00434 ECONNABORTED 103 Software caused connection abort 00435 ECONNRESET 104 Connection reset by peer 00436 ENOBUFS 105 No buffer space available 00437 EISCONN 106 Transport endpoint is already connected 00438 ENOTCONN 107 Transport endpoint is not connected 00439 ESHUTDOWN 108 Cannot send after transport endpoint shutdown 00440 ETOOMANYREFS 109 Too many references: cannot splice 00441 ETIMEDOUT 110 Connection timed out 00442 ECONNREFUSED 111 Connection refused 00443 EHOSTDOWN 112 Host is down 00444 EHOSTUNREACH 113 No route to host 00445 EALREADY 114 Operation already in progress 00446 EINPROGRESS 115 Operation now in progress 00447 ESTALE 116 Stale NFS file handle 00448 EUCLEAN 117 Structure needs cleaning 00449 ENOTNAM 118 Not a XENIX named type file 00450 ENAVAIL 119 No XENIX semaphores available 00451 EISNAM 120 Is a named type file 00452 EREMOTEIO 121 Remote I/O error 00453 EDQUOT 122 Quota exceeded 00454 ENOMEDIUM 123 No medium found 00455 EMEDIUMTYPE 124 Wrong medium type 00456 ECANCELED 125 Operation Canceled 00457 ENOKEY 126 Required key not available 00458 EKEYEXPIRED 127 Key has expired 00459 EKEYREVOKED 128 Key has been revoked 00460 EKEYREJECTED 129 Key was rejected by service 00461 EOWNERDEAD 130 Owner died 00462 ENOTRECOVERABLE 131 State not recoverable 00463 \endverbatim 00464 * 00465 * @note 00466 * MbedOS System Error codes are defined using the macro MBED_DEFINE_SYSTEM_ERROR\n 00467 * For example MBED_DEFINE_SYSTEM_ERROR( INVALID_ARGUMENT ,1 ) macro defines the following values:\n 00468 * ERROR_CODE_INVALID_ARGUMENT = MBED_SYSTEM_ERROR_BASE+1\n 00469 * ERROR_INVALID_ARGUMENT = MAKE_MBED_ERROR(ERROR_TYPE_SYSTEM, MBED_MODULE_UNKNOWN, ERROR_CODE_INVALID_ARGUMENT)\n 00470 * Its effectively equivalent to:\n 00471 * ERROR_CODE_INVALID_ARGUMENT = 1\n 00472 * ERROR_INVALID_ARGUMENT = 0x80FF0001\n (Note that MODULE field is set to MBED_MODULE_UNKNOWN) 00473 * New System Error codes should be defined using MBED_DEFINE_SYSTEM_ERROR macro and must have an unique error code value\n 00474 * passed as the second argument in the MBED_DEFINE_SYSTEM_ERROR macro.\n\n 00475 * Below are the Mbed System error codes and the description: 00476 * \verbatim 00477 UNKNOWN 256 Unknown error 00478 INVALID_ARGUMENT 257 Invalid Argument 00479 INVALID_DATA 258 Invalid data 00480 INVALID_FORMAT 259 Invalid format 00481 INVALID_INDEX 260 Invalid Index 00482 INVALID_SIZE 261 Invalid Size 00483 INVALID_OPERATION 262 Invalid Operation 00484 NOT_FOUND 263 Not Found 00485 ACCESS_DENIED 264 Access Denied 00486 NOT_SUPPORTED 265 Not supported 00487 BUFFER_FULL 266 Buffer Full 00488 MEDIA_FULL 267 Media/Disk Full 00489 ALREADY_IN_USE 268 Already in use 00490 TIMEOUT 269 Timeout error 00491 NOT_READY 270 Not Ready 00492 FAILED_OPERATION 271 Requested Operation failed 00493 OPERATION_PROHIBITED 272 Operation prohibited 00494 OPERATION_ABORTED 273 Operation failed 00495 WRITE_PROTECTED 274 Attempt to write to write-protected resource 00496 NO_RESPONSE 275 No response 00497 SEMAPHORE_LOCK_FAILED 276 Semaphore lock failed 00498 MUTEX_LOCK_FAILED 277 Mutex lock failed 00499 SEMAPHORE_UNLOCK_FAILED 278 Semaphore unlock failed 00500 MUTEX_UNLOCK_FAILED 279 Mutex unlock failed 00501 CRC_ERROR 280 CRC error or mismatch 00502 OPEN_FAILED 281 Open failed 00503 CLOSE_FAILED 282 Close failed 00504 READ_FAILED 283 Read failed 00505 WRITE_FAILED 284 Write failed 00506 INITIALIZATION_FAILED 285 Initialization failed 00507 BOOT_FAILURE 286 Boot failure 00508 OUT_OF_MEMORY 287 Out of memory 00509 OUT_OF_RESOURCES 288 Out of resources 00510 ALLOC_FAILED 289 Alloc failed 00511 FREE_FAILED 290 Free failed 00512 OVERFLOW 291 Overflow error 00513 UNDERFLOW 292 Underflow error 00514 STACK_OVERFLOW 293 Stack overflow error 00515 ISR_QUEUE_OVERFLOW 294 ISR queue overflow 00516 TIMER_QUEUE_OVERFLOW 295 Timer Queue overflow 00517 CLIB_SPACE_UNAVAILABLE 296 Standard library error - Space unavailable 00518 CLIB_EXCEPTION 297 Standard library error - Exception 00519 CLIB_MUTEX_INIT_FAILURE 298 Standard library error - Mutex Init failure 00520 CREATE_FAILED 299 Create failed 00521 DELETE_FAILED 300 Delete failed 00522 THREAD_CREATE_FAILED 301 Thread Create failed 00523 THREAD_DELETE_FAILED 302 Thread Delete failed 00524 PROHIBITED_IN_ISR_CONTEXT 303 Operation Prohibited in ISR context 00525 PINMAP_INVALID 304 Pinmap Invalid 00526 RTOS_EVENT 305 Unknown Rtos Error 00527 RTOS_THREAD_EVENT 306 Rtos Thread Error 00528 RTOS_MUTEX_EVENT 307 Rtos Mutex Error 00529 RTOS_SEMAPHORE_EVENT 308 Rtos Semaphore Error 00530 RTOS_MEMORY_POOL_EVENT 309 Rtos Memory Pool Error 00531 RTOS_TIMER_EVENT 310 Rtos Timer Error 00532 RTOS_EVENT_FLAGS_EVENT 311 Rtos Event flags Error 00533 RTOS_MESSAGE_QUEUE_EVENT 312 Rtos Message queue Error 00534 DEVICE_BUSY 313 Device Busy 00535 CONFIG_UNSUPPORTED 314 Configuration not supported 00536 CONFIG_MISMATCH 315 Configuration mismatch 00537 ALREADY_INITIALIZED 316 Already initialized 00538 HARDFAULT_EXCEPTION 317 HardFault exception 00539 MEMMANAGE_EXCEPTION 318 MemManage exception 00540 BUSFAULT_EXCEPTION 319 BusFault exception 00541 USAGEFAULT_EXCEPTION 320 UsageFault exception 00542 BLE_NO_FRAME_INITIALIZED, 321 BLE No frame initialized 00543 BLE_BACKEND_CREATION_FAILED 322 BLE Backend creation failed 00544 BLE_BACKEND_NOT_INITIALIZED 323 BLE Backend not initialized 00545 ASSERTION_FAILED 324 Assertion Failed 00546 AUTHENTICATION_FAILED 325 Authentication Failed 00547 RBP_AUTHENTICATION_FAILED 326 Rollback Protect Authentication Failed 00548 \endverbatim 00549 * 00550 * @note 00551 * Custom Error codes can be defined using the macro DEFINE_CUSTOM_ERROR\n 00552 * This is mainly meant to capture non-generic error codes specific to a device. 00553 * For example DEFINE_CUSTOM_ERROR( MY_CUSTOM_ERROR ,1 ) macro defines the following values:\n 00554 * ERROR_CODE_MY_CUSTOM_ERROR = MBED_CUSTOM_ERROR_BASE+1\n 00555 * ERROR_MY_CUSTOM_ERROR = MAKE_MBED_ERROR(ERROR_TYPE_CUSTOM, MBED_MODULE_UNKNOWN, ERROR_CODE_MY_CUSTOM_ERROR)\n 00556 * Its effectively equivalent to:\n 00557 * ERROR_CODE_MY_CUSTOM_ERROR = 4097\n 00558 * ERROR_MY_CUSTOM_ERROR = 0xA0FF1001\n (Note that MODULE field is set to MBED_MODULE_UNKNOWN) \n\n 00559 * 00560 * @note 00561 * **Using error codes:** \n 00562 * POSIX error codes may be used in modules/functions currently using POSIX error codes and switching them to Mbed-OS error codes 00563 * may cause interoperability issues. For example, some of the filesystem, network stack implementations may need to use 00564 * POSIX error codes in order to keep them compatible with other modules interfacing with them, and may continue to use POSIX error codes. 00565 * 00566 * In all other cases, like for any native development of Mbed-OS modules Mbed-OS error codes should be used. 00567 * This makes it easy to use Mbed-OS error reporting/logging infrastructure and makes debugging error scenarios 00568 * much more efficient. 00569 * 00570 * @note 00571 * **Searching for error codes in mbed-os source tree:** \n 00572 * If you get an error report as below which you want to search for in mbed-os source tree, first take note of "Error Code" number. \n 00573 * For example, the below error report has an error code of \b 259. Find the error name associated with the error code and in this case its \b INVALID_FORMAT. \n 00574 * Use that error name(\b INVALID_FORMAT) to search the source tree for code locations setting that specific error code. \n 00575 * If the Error module reported is not 255(which indicates unknown module), you can also use that to narrow down to the specific component reporting the error. 00576 * See mbed_module_type_t enum above for module mapping. \n 00577 * 00578 * \verbatim 00579 ++ MbedOS Error Info ++ 00580 Error Status: 0x80FF013D Code: 317 Module: 255 00581 Error Message: Fault exception 00582 Location: 0x5CD1 00583 Error Value: 0x4A2A 00584 Current Thread: Id: 0x20001E80 Entry: 0x5EB1 StackSize: 0x1000 StackMem: 0x20000E80 SP: 0x2002FF90 00585 For more info, visit: https://mbed.com/s/error?error=0x80FF013D&mbedos=999999&core=0x410FC241&compile=1&ver=5060528 00586 -- MbedOS Error Info -- 00587 \endverbatim 00588 */ 00589 00590 typedef enum _mbed_error_code { 00591 //Below are POSIX ERROR CODE definitions, which starts at MBED_POSIX_ERROR_BASE(=0) 00592 //POSIX ERROR CODE definitions starts at offset 0(MBED_POSIX_ERROR_BASE) to align them with actual POSIX Error Code 00593 //defintions in mbed_retarget.h 00594 // Error Name Error Code 00595 MBED_DEFINE_POSIX_ERROR(EPERM, EPERM), /* 1 Operation not permitted */ 00596 MBED_DEFINE_POSIX_ERROR(ENOENT, ENOENT), /* 2 No such file or directory */ 00597 MBED_DEFINE_POSIX_ERROR(ESRCH, ESRCH), /* 3 No such process */ 00598 MBED_DEFINE_POSIX_ERROR(EINTR, EINTR), /* 4 Interrupted system call */ 00599 MBED_DEFINE_POSIX_ERROR(EIO, EIO), /* 5 I/O error */ 00600 MBED_DEFINE_POSIX_ERROR(ENXIO, ENXIO), /* 6 No such device or address */ 00601 MBED_DEFINE_POSIX_ERROR(E2BIG, E2BIG), /* 7 Argument list too long */ 00602 MBED_DEFINE_POSIX_ERROR(ENOEXEC, ENOEXEC), /* 8 Exec format error */ 00603 MBED_DEFINE_POSIX_ERROR(EBADF, EBADF), /* 9 Bad file number */ 00604 MBED_DEFINE_POSIX_ERROR(ECHILD, ECHILD), /* 10 No child processes */ 00605 MBED_DEFINE_POSIX_ERROR(EAGAIN, EAGAIN), /* 11 Try again */ 00606 MBED_DEFINE_POSIX_ERROR(ENOMEM, ENOMEM), /* 12 Out of memory */ 00607 MBED_DEFINE_POSIX_ERROR(EACCES, EACCES), /* 13 Permission denied */ 00608 MBED_DEFINE_POSIX_ERROR(EFAULT, EFAULT), /* 14 Bad address */ 00609 MBED_DEFINE_POSIX_ERROR(ENOTBLK, ENOTBLK), /* 15 Block device required */ 00610 MBED_DEFINE_POSIX_ERROR(EBUSY, EBUSY), /* 16 Device or resource busy */ 00611 MBED_DEFINE_POSIX_ERROR(EEXIST, EEXIST), /* 17 File exists */ 00612 MBED_DEFINE_POSIX_ERROR(EXDEV, EXDEV), /* 18 Cross-device link */ 00613 MBED_DEFINE_POSIX_ERROR(ENODEV, ENODEV), /* 19 No such device */ 00614 MBED_DEFINE_POSIX_ERROR(ENOTDIR, ENOTDIR), /* 20 Not a directory */ 00615 MBED_DEFINE_POSIX_ERROR(EISDIR, EISDIR), /* 21 Is a directory */ 00616 MBED_DEFINE_POSIX_ERROR(EINVAL, EINVAL), /* 22 Invalid argument */ 00617 MBED_DEFINE_POSIX_ERROR(ENFILE, ENFILE), /* 23 File table overflow */ 00618 MBED_DEFINE_POSIX_ERROR(EMFILE, EMFILE), /* 24 Too many open files */ 00619 MBED_DEFINE_POSIX_ERROR(ENOTTY, ENOTTY), /* 25 Not a typewriter */ 00620 MBED_DEFINE_POSIX_ERROR(ETXTBSY, ETXTBSY), /* 26 Text file busy */ 00621 MBED_DEFINE_POSIX_ERROR(EFBIG, EFBIG), /* 27 File too large */ 00622 MBED_DEFINE_POSIX_ERROR(ENOSPC, ENOSPC), /* 28 No space left on device */ 00623 MBED_DEFINE_POSIX_ERROR(ESPIPE, ESPIPE), /* 29 Illegal seek */ 00624 MBED_DEFINE_POSIX_ERROR(EROFS, EROFS), /* 30 Read-only file system */ 00625 MBED_DEFINE_POSIX_ERROR(EMLINK, EMLINK), /* 31 Too many links */ 00626 MBED_DEFINE_POSIX_ERROR(EPIPE, EPIPE), /* 32 Broken pipe */ 00627 MBED_DEFINE_POSIX_ERROR(EDOM, EDOM), /* 33 Math argument out of domain of func */ 00628 MBED_DEFINE_POSIX_ERROR(ERANGE, ERANGE), /* 34 Math result not representable */ 00629 MBED_DEFINE_POSIX_ERROR(EDEADLK, EDEADLK), /* 35 Resource deadlock would occur */ 00630 MBED_DEFINE_POSIX_ERROR(ENAMETOOLONG, ENAMETOOLONG), /* 36 File name too long */ 00631 MBED_DEFINE_POSIX_ERROR(ENOLCK, ENOLCK), /* 37 No record locks available */ 00632 MBED_DEFINE_POSIX_ERROR(ENOSYS, ENOSYS), /* 38 Function not implemented */ 00633 MBED_DEFINE_POSIX_ERROR(ENOTEMPTY, ENOTEMPTY), /* 39 Directory not empty */ 00634 MBED_DEFINE_POSIX_ERROR(ELOOP, ELOOP), /* 40 Too many symbolic links encountered */ 00635 MBED_DEFINE_POSIX_ERROR(EWOULDBLOCK, EAGAIN), /* EAGAIN Operation would block */ 00636 MBED_DEFINE_POSIX_ERROR(ENOMSG, ENOMSG), /* 42 No message of desired type */ 00637 MBED_DEFINE_POSIX_ERROR(EIDRM, EIDRM), /* 43 Identifier removed */ 00638 MBED_DEFINE_POSIX_ERROR(ECHRNG, ECHRNG), /* 44 Channel number out of range */ 00639 MBED_DEFINE_POSIX_ERROR(EL2NSYNC, EL2NSYNC), /* 45 Level 2 not synchronized */ 00640 MBED_DEFINE_POSIX_ERROR(EL3HLT, EL3HLT), /* 46 Level 3 halted */ 00641 MBED_DEFINE_POSIX_ERROR(EL3RST, EL3RST), /* 47 Level 3 reset */ 00642 MBED_DEFINE_POSIX_ERROR(ELNRNG, ELNRNG), /* 48 Link number out of range */ 00643 MBED_DEFINE_POSIX_ERROR(EUNATCH, EUNATCH), /* 49 Protocol driver not attached */ 00644 MBED_DEFINE_POSIX_ERROR(ENOCSI, ENOCSI), /* 50 No CSI structure available */ 00645 MBED_DEFINE_POSIX_ERROR(EL2HLT, EL2HLT), /* 51 Level 2 halted */ 00646 MBED_DEFINE_POSIX_ERROR(EBADE, EBADE), /* 52 Invalid exchange */ 00647 MBED_DEFINE_POSIX_ERROR(EBADR, EBADR), /* 53 Invalid request descriptor */ 00648 MBED_DEFINE_POSIX_ERROR(EXFULL, EXFULL), /* 54 Exchange full */ 00649 MBED_DEFINE_POSIX_ERROR(ENOANO, ENOANO), /* 55 No anode */ 00650 MBED_DEFINE_POSIX_ERROR(EBADRQC, EBADRQC), /* 56 Invalid request code */ 00651 MBED_DEFINE_POSIX_ERROR(EBADSLT, EBADSLT), /* 57 Invalid slot */ 00652 MBED_DEFINE_POSIX_ERROR(EDEADLOCK, EDEADLK), /* EDEADLK Resource deadlock would occur */ 00653 MBED_DEFINE_POSIX_ERROR(EBFONT, EBFONT), /* 59 Bad font file format */ 00654 MBED_DEFINE_POSIX_ERROR(ENOSTR, ENOSTR), /* 60 Device not a stream */ 00655 MBED_DEFINE_POSIX_ERROR(ENODATA, ENODATA), /* 61 No data available */ 00656 MBED_DEFINE_POSIX_ERROR(ETIME, ETIME), /* 62 Timer expired */ 00657 MBED_DEFINE_POSIX_ERROR(ENOSR, ENOSR), /* 63 Out of streams resources */ 00658 MBED_DEFINE_POSIX_ERROR(ENONET, ENONET), /* 64 Machine is not on the network */ 00659 MBED_DEFINE_POSIX_ERROR(ENOPKG, ENOPKG), /* 65 Package not installed */ 00660 MBED_DEFINE_POSIX_ERROR(EREMOTE, EREMOTE), /* 66 Object is remote */ 00661 MBED_DEFINE_POSIX_ERROR(ENOLINK, ENOLINK), /* 67 Link has been severed */ 00662 MBED_DEFINE_POSIX_ERROR(EADV, EADV), /* 68 Advertise error */ 00663 MBED_DEFINE_POSIX_ERROR(ESRMNT, ESRMNT), /* 69 Srmount error */ 00664 MBED_DEFINE_POSIX_ERROR(ECOMM, ECOMM), /* 70 Communication error on send */ 00665 MBED_DEFINE_POSIX_ERROR(EPROTO, EPROTO), /* 71 Protocol error */ 00666 MBED_DEFINE_POSIX_ERROR(EMULTIHOP, EMULTIHOP), /* 72 Multihop attempted */ 00667 MBED_DEFINE_POSIX_ERROR(EDOTDOT, EDOTDOT), /* 73 RFS specific error */ 00668 MBED_DEFINE_POSIX_ERROR(EBADMSG, EBADMSG), /* 74 Not a data message */ 00669 MBED_DEFINE_POSIX_ERROR(EOVERFLOW, EOVERFLOW), /* 75 Value too large for defined data type */ 00670 MBED_DEFINE_POSIX_ERROR(ENOTUNIQ, ENOTUNIQ), /* 76 Name not unique on network */ 00671 MBED_DEFINE_POSIX_ERROR(EBADFD, EBADFD), /* 77 File descriptor in bad state */ 00672 MBED_DEFINE_POSIX_ERROR(EREMCHG, EREMCHG), /* 78 Remote address changed */ 00673 MBED_DEFINE_POSIX_ERROR(ELIBACC, ELIBACC), /* 79 Can not access a needed shared library */ 00674 MBED_DEFINE_POSIX_ERROR(ELIBBAD, ELIBBAD), /* 80 Accessing a corrupted shared library */ 00675 MBED_DEFINE_POSIX_ERROR(ELIBSCN, ELIBSCN), /* 81 .lib section in a.out corrupted */ 00676 MBED_DEFINE_POSIX_ERROR(ELIBMAX, ELIBMAX), /* 82 Attempting to link in too many shared libraries */ 00677 MBED_DEFINE_POSIX_ERROR(ELIBEXEC, ELIBEXEC), /* 83 Cannot exec a shared library directly */ 00678 MBED_DEFINE_POSIX_ERROR(EILSEQ, EILSEQ), /* 84 Illegal byte sequence */ 00679 MBED_DEFINE_POSIX_ERROR(ERESTART, ERESTART), /* 85 Interrupted system call should be restarted */ 00680 MBED_DEFINE_POSIX_ERROR(ESTRPIPE, ESTRPIPE), /* 86 Streams pipe error */ 00681 MBED_DEFINE_POSIX_ERROR(EUSERS, EUSERS), /* 87 Too many users */ 00682 MBED_DEFINE_POSIX_ERROR(ENOTSOCK, ENOTSOCK), /* 88 Socket operation on non-socket */ 00683 MBED_DEFINE_POSIX_ERROR(EDESTADDRREQ, EDESTADDRREQ), /* 89 Destination address required */ 00684 MBED_DEFINE_POSIX_ERROR(EMSGSIZE, EMSGSIZE), /* 90 Message too long */ 00685 MBED_DEFINE_POSIX_ERROR(EPROTOTYPE, EPROTOTYPE), /* 91 Protocol wrong type for socket */ 00686 MBED_DEFINE_POSIX_ERROR(ENOPROTOOPT, ENOPROTOOPT), /* 92 Protocol not available */ 00687 MBED_DEFINE_POSIX_ERROR(EPROTONOSUPPORT, EPROTONOSUPPORT), /* 93 Protocol not supported */ 00688 MBED_DEFINE_POSIX_ERROR(ESOCKTNOSUPPORT, ESOCKTNOSUPPORT), /* 94 Socket type not supported */ 00689 MBED_DEFINE_POSIX_ERROR(EOPNOTSUPP, EOPNOTSUPP), /* 95 Operation not supported on transport endpoint */ 00690 MBED_DEFINE_POSIX_ERROR(EPFNOSUPPORT, EPFNOSUPPORT), /* 96 Protocol family not supported */ 00691 MBED_DEFINE_POSIX_ERROR(EAFNOSUPPORT, EAFNOSUPPORT), /* 97 Address family not supported by protocol */ 00692 MBED_DEFINE_POSIX_ERROR(EADDRINUSE, EADDRINUSE), /* 98 Address already in use */ 00693 MBED_DEFINE_POSIX_ERROR(EADDRNOTAVAIL, EADDRNOTAVAIL), /* 99 Cannot assign requested address */ 00694 MBED_DEFINE_POSIX_ERROR(ENETDOWN, ENETDOWN), /* 100 Network is down */ 00695 MBED_DEFINE_POSIX_ERROR(ENETUNREACH, ENETUNREACH), /* 101 Network is unreachable */ 00696 MBED_DEFINE_POSIX_ERROR(ENETRESET, ENETRESET), /* 102 Network dropped connection because of reset */ 00697 MBED_DEFINE_POSIX_ERROR(ECONNABORTED, ECONNABORTED), /* 103 Software caused connection abort */ 00698 MBED_DEFINE_POSIX_ERROR(ECONNRESET, ECONNRESET), /* 104 Connection reset by peer */ 00699 MBED_DEFINE_POSIX_ERROR(ENOBUFS, ENOBUFS), /* 105 No buffer space available */ 00700 MBED_DEFINE_POSIX_ERROR(EISCONN, EISCONN), /* 106 Transport endpoint is already connected */ 00701 MBED_DEFINE_POSIX_ERROR(ENOTCONN, ENOTCONN), /* 107 Transport endpoint is not connected */ 00702 MBED_DEFINE_POSIX_ERROR(ESHUTDOWN, ESHUTDOWN), /* 108 Cannot send after transport endpoint shutdown */ 00703 MBED_DEFINE_POSIX_ERROR(ETOOMANYREFS, ETOOMANYREFS), /* 109 Too many references: cannot splice */ 00704 MBED_DEFINE_POSIX_ERROR(ETIMEDOUT, ETIMEDOUT), /* 110 Connection timed out */ 00705 MBED_DEFINE_POSIX_ERROR(ECONNREFUSED, ECONNREFUSED), /* 111 Connection refused */ 00706 MBED_DEFINE_POSIX_ERROR(EHOSTDOWN, EHOSTDOWN), /* 112 Host is down */ 00707 MBED_DEFINE_POSIX_ERROR(EHOSTUNREACH, EHOSTUNREACH), /* 113 No route to host */ 00708 MBED_DEFINE_POSIX_ERROR(EALREADY, EALREADY), /* 114 Operation already in progress */ 00709 MBED_DEFINE_POSIX_ERROR(EINPROGRESS, EINPROGRESS), /* 115 Operation now in progress */ 00710 MBED_DEFINE_POSIX_ERROR(ESTALE, ESTALE), /* 116 Stale NFS file handle */ 00711 MBED_DEFINE_POSIX_ERROR(EUCLEAN, EUCLEAN), /* 117 Structure needs cleaning */ 00712 MBED_DEFINE_POSIX_ERROR(ENOTNAM, ENOTNAM), /* 118 Not a XENIX named type file */ 00713 MBED_DEFINE_POSIX_ERROR(ENAVAIL, ENAVAIL), /* 119 No XENIX semaphores available */ 00714 MBED_DEFINE_POSIX_ERROR(EISNAM, EISNAM), /* 120 Is a named type file */ 00715 MBED_DEFINE_POSIX_ERROR(EREMOTEIO, EREMOTEIO), /* 121 Remote I/O error */ 00716 MBED_DEFINE_POSIX_ERROR(EDQUOT, EDQUOT), /* 122 Quota exceeded */ 00717 MBED_DEFINE_POSIX_ERROR(ENOMEDIUM, ENOMEDIUM), /* 123 No medium found */ 00718 MBED_DEFINE_POSIX_ERROR(EMEDIUMTYPE, EMEDIUMTYPE), /* 124 Wrong medium type */ 00719 MBED_DEFINE_POSIX_ERROR(ECANCELED, ECANCELED), /* 125 Operation Canceled */ 00720 MBED_DEFINE_POSIX_ERROR(ENOKEY, ENOKEY), /* 126 Required key not available */ 00721 MBED_DEFINE_POSIX_ERROR(EKEYEXPIRED, EKEYEXPIRED), /* 127 Key has expired */ 00722 MBED_DEFINE_POSIX_ERROR(EKEYREVOKED, EKEYREVOKED), /* 128 Key has been revoked */ 00723 MBED_DEFINE_POSIX_ERROR(EKEYREJECTED, EKEYREJECTED), /* 129 Key was rejected by service */ 00724 MBED_DEFINE_POSIX_ERROR(EOWNERDEAD, EOWNERDEAD), /* 130 Owner died */ 00725 MBED_DEFINE_POSIX_ERROR(ENOTRECOVERABLE, ENOTRECOVERABLE), /* 131 State not recoverable */ 00726 00727 //Below are MBED SYSTEM ERROR CODE definitions 00728 //MBED SYSTEM ERROR CODE definitions starts at offset MBED_SYSTEM_ERROR_BASE, see above. 00729 // Error Name Error Offset Error Code 00730 MBED_DEFINE_SYSTEM_ERROR(UNKNOWN, 0), /* 256 Unknown error */ 00731 MBED_DEFINE_SYSTEM_ERROR(INVALID_ARGUMENT, 1), /* 257 Invalid Argument */ 00732 MBED_DEFINE_SYSTEM_ERROR(INVALID_DATA_DETECTED, 2), /* 258 Invalid data detected */ 00733 MBED_DEFINE_SYSTEM_ERROR(INVALID_FORMAT, 3), /* 259 Invalid format */ 00734 MBED_DEFINE_SYSTEM_ERROR(INVALID_INDEX, 4), /* 260 Invalid Index */ 00735 MBED_DEFINE_SYSTEM_ERROR(INVALID_SIZE, 5), /* 261 Invalid Size */ 00736 MBED_DEFINE_SYSTEM_ERROR(INVALID_OPERATION, 6), /* 262 Invalid Operation */ 00737 MBED_DEFINE_SYSTEM_ERROR(ITEM_NOT_FOUND, 7), /* 263 Item Not Found */ 00738 MBED_DEFINE_SYSTEM_ERROR(ACCESS_DENIED, 8), /* 264 Access Denied */ 00739 MBED_DEFINE_SYSTEM_ERROR(UNSUPPORTED, 9), /* 265 Unsupported */ 00740 MBED_DEFINE_SYSTEM_ERROR(BUFFER_FULL, 10), /* 266 Buffer Full */ 00741 MBED_DEFINE_SYSTEM_ERROR(MEDIA_FULL, 11), /* 267 Media/Disk Full */ 00742 MBED_DEFINE_SYSTEM_ERROR(ALREADY_IN_USE, 12), /* 268 Already in use */ 00743 MBED_DEFINE_SYSTEM_ERROR(TIME_OUT, 13), /* 269 Timeout error */ 00744 MBED_DEFINE_SYSTEM_ERROR(NOT_READY, 14), /* 270 Not Ready */ 00745 MBED_DEFINE_SYSTEM_ERROR(FAILED_OPERATION, 15), /* 271 Requested Operation failed */ 00746 MBED_DEFINE_SYSTEM_ERROR(OPERATION_PROHIBITED, 16), /* 272 Operation prohibited */ 00747 MBED_DEFINE_SYSTEM_ERROR(OPERATION_ABORTED, 17), /* 273 Operation failed */ 00748 MBED_DEFINE_SYSTEM_ERROR(WRITE_PROTECTED, 18), /* 274 Attempt to write to write-protected resource */ 00749 MBED_DEFINE_SYSTEM_ERROR(NO_RESPONSE, 19), /* 275 No response */ 00750 MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_LOCK_FAILED, 20), /* 276 Semaphore lock failed */ 00751 MBED_DEFINE_SYSTEM_ERROR(MUTEX_LOCK_FAILED, 21), /* 277 Mutex lock failed */ 00752 MBED_DEFINE_SYSTEM_ERROR(SEMAPHORE_UNLOCK_FAILED, 22), /* 278 Semaphore unlock failed */ 00753 MBED_DEFINE_SYSTEM_ERROR(MUTEX_UNLOCK_FAILED, 23), /* 279 Mutex unlock failed */ 00754 MBED_DEFINE_SYSTEM_ERROR(CRC_ERROR, 24), /* 280 CRC error or mismatch */ 00755 MBED_DEFINE_SYSTEM_ERROR(OPEN_FAILED, 25), /* 281 Open failed */ 00756 MBED_DEFINE_SYSTEM_ERROR(CLOSE_FAILED, 26), /* 282 Close failed */ 00757 MBED_DEFINE_SYSTEM_ERROR(READ_FAILED, 27), /* 283 Read failed */ 00758 MBED_DEFINE_SYSTEM_ERROR(WRITE_FAILED, 28), /* 284 Write failed */ 00759 MBED_DEFINE_SYSTEM_ERROR(INITIALIZATION_FAILED, 29), /* 285 Initialization failed */ 00760 MBED_DEFINE_SYSTEM_ERROR(BOOT_FAILURE, 30), /* 286 Boot failure */ 00761 MBED_DEFINE_SYSTEM_ERROR(OUT_OF_MEMORY, 31), /* 287 Out of memory */ 00762 MBED_DEFINE_SYSTEM_ERROR(OUT_OF_RESOURCES, 32), /* 288 Out of resources */ 00763 MBED_DEFINE_SYSTEM_ERROR(ALLOC_FAILED, 33), /* 289 Alloc failed */ 00764 MBED_DEFINE_SYSTEM_ERROR(FREE_FAILED, 34), /* 290 Free failed */ 00765 MBED_DEFINE_SYSTEM_ERROR(OVERFLOW, 35), /* 291 Overflow error */ 00766 MBED_DEFINE_SYSTEM_ERROR(UNDERFLOW, 36), /* 292 Underflow error */ 00767 MBED_DEFINE_SYSTEM_ERROR(STACK_OVERFLOW, 37), /* 293 Stack overflow error */ 00768 MBED_DEFINE_SYSTEM_ERROR(ISR_QUEUE_OVERFLOW, 38), /* 294 ISR queue overflow */ 00769 MBED_DEFINE_SYSTEM_ERROR(TIMER_QUEUE_OVERFLOW, 39), /* 295 Timer Queue overflow */ 00770 MBED_DEFINE_SYSTEM_ERROR(CLIB_SPACE_UNAVAILABLE, 40), /* 296 Standard library error - Space unavailable */ 00771 MBED_DEFINE_SYSTEM_ERROR(CLIB_EXCEPTION, 41), /* 297 Standard library error - Exception */ 00772 MBED_DEFINE_SYSTEM_ERROR(CLIB_MUTEX_INIT_FAILURE, 42), /* 298 Standard library error - Mutex Init failure */ 00773 MBED_DEFINE_SYSTEM_ERROR(CREATE_FAILED, 43), /* 299 Create failed */ 00774 MBED_DEFINE_SYSTEM_ERROR(DELETE_FAILED, 44), /* 300 Delete failed */ 00775 MBED_DEFINE_SYSTEM_ERROR(THREAD_CREATE_FAILED, 45), /* 301 Thread Create failed */ 00776 MBED_DEFINE_SYSTEM_ERROR(THREAD_DELETE_FAILED, 46), /* 302 Thread Delete failed */ 00777 MBED_DEFINE_SYSTEM_ERROR(PROHIBITED_IN_ISR_CONTEXT, 47), /* 303 Operation Prohibited in ISR context */ 00778 MBED_DEFINE_SYSTEM_ERROR(PINMAP_INVALID, 48), /* 304 Pinmap Invalid */ 00779 MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT, 49), /* 305 Unknown Rtos Error */ 00780 MBED_DEFINE_SYSTEM_ERROR(RTOS_THREAD_EVENT, 50), /* 306 Rtos Thread Error */ 00781 MBED_DEFINE_SYSTEM_ERROR(RTOS_MUTEX_EVENT, 51), /* 307 Rtos Mutex Error */ 00782 MBED_DEFINE_SYSTEM_ERROR(RTOS_SEMAPHORE_EVENT, 52), /* 308 Rtos Semaphore Error */ 00783 MBED_DEFINE_SYSTEM_ERROR(RTOS_MEMORY_POOL_EVENT, 53), /* 309 Rtos Memory Pool Error */ 00784 MBED_DEFINE_SYSTEM_ERROR(RTOS_TIMER_EVENT, 54), /* 310 Rtos Timer Error */ 00785 MBED_DEFINE_SYSTEM_ERROR(RTOS_EVENT_FLAGS_EVENT, 55), /* 311 Rtos Event flags Error */ 00786 MBED_DEFINE_SYSTEM_ERROR(RTOS_MESSAGE_QUEUE_EVENT, 56), /* 312 Rtos Message queue Error */ 00787 MBED_DEFINE_SYSTEM_ERROR(DEVICE_BUSY, 57), /* 313 Device Busy */ 00788 MBED_DEFINE_SYSTEM_ERROR(CONFIG_UNSUPPORTED, 58), /* 314 Configuration not supported */ 00789 MBED_DEFINE_SYSTEM_ERROR(CONFIG_MISMATCH, 59), /* 315 Configuration mismatch */ 00790 MBED_DEFINE_SYSTEM_ERROR(ALREADY_INITIALIZED, 60), /* 316 Already initialized */ 00791 MBED_DEFINE_SYSTEM_ERROR(HARDFAULT_EXCEPTION, 61), /* 317 HardFault exception */ 00792 MBED_DEFINE_SYSTEM_ERROR(MEMMANAGE_EXCEPTION, 62), /* 318 MemManage exception */ 00793 MBED_DEFINE_SYSTEM_ERROR(BUSFAULT_EXCEPTION, 63), /* 319 BusFault exception */ 00794 MBED_DEFINE_SYSTEM_ERROR(USAGEFAULT_EXCEPTION, 64), /* 320 UsageFault exception*/ 00795 MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */ 00796 MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */ 00797 MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */ 00798 MBED_DEFINE_SYSTEM_ERROR(ASSERTION_FAILED, 68), /* 324 Assertion Failed */ 00799 MBED_DEFINE_SYSTEM_ERROR(AUTHENTICATION_FAILED, 69), /* 325 Authentication Failed */ 00800 MBED_DEFINE_SYSTEM_ERROR(RBP_AUTHENTICATION_FAILED, 70), /* 326 Rollback Protection Authentication Failed */ 00801 MBED_DEFINE_SYSTEM_ERROR(BLE_USE_INCOMPATIBLE_API, 71), /* 327 Concurrent use of incompatible versions of a BLE API */ 00802 MBED_DEFINE_SYSTEM_ERROR(BLE_ILLEGAL_STATE, 72), /* 328 BLE stack entered illegal state */ 00803 00804 //Everytime you add a new system error code, you must update 00805 //Error documentation under Handbook to capture the info on 00806 //the new error status/codes 00807 00808 //MBED CUSTOM ERROR CODE definitions starts at offset MBED_CUSTOM_ERROR_BASE, see above. 00809 /* Add More/Custom Error Codes here, See example below */ 00810 //DEFINE_CUSTOM_ERROR( MY_CUSTOM_ERROR , 1 ), 00811 00812 } mbed_error_code_t; 00813 00814 /** mbed_error_ctx struct 00815 * 00816 * This struct captures the context information at the time of error.\n 00817 * It primarily contains information about the thread where the error originated,\n 00818 * filename/line number of the source file where the error occurred, a context specific error value(error_value)\n 00819 * and the address where the error originated.\n 00820 * 00821 * @note 00822 * Below are the members of mbed_error_ctx struct\n 00823 * error_status mbed_error_status_t value for this error\n 00824 * error_function_address Address where the error occurred\n 00825 * thread_id ID of the thread which generated the error\n 00826 * thread_entry_address Entry function of the thread which generated the error\n 00827 * thread_stack_size Stack Size of the thread which generated the error\n 00828 * thread_stack_mem Stack Top of the thread which generated the error\n 00829 * thread_current_sp Current Stack Pointer of the thread which generated the error\n 00830 * error_value A context/error specific value associated with this error\n 00831 * error_filename Filename where the error originated\n 00832 * error_line_number Line number in error_filename where the error originated\n 00833 */ 00834 typedef struct _mbed_error_ctx { 00835 mbed_error_status_t error_status; 00836 uint32_t error_address; 00837 uint32_t error_value; 00838 uint32_t thread_id; 00839 uint32_t thread_entry_address; 00840 uint32_t thread_stack_size; 00841 uint32_t thread_stack_mem; 00842 uint32_t thread_current_sp; 00843 #ifdef MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN 00844 char error_filename[MBED_CONF_PLATFORM_MAX_ERROR_FILENAME_LEN]; 00845 uint32_t error_line_number; 00846 #endif 00847 #if MBED_CONF_PLATFORM_CRASH_CAPTURE_ENABLED 00848 int32_t error_reboot_count;//everytime we write this struct we increment this value by 1, irrespective of time between reboots. Note that the data itself might change, but everytime we reboot due to error we update this count by 1 00849 int32_t is_error_processed;//once this error is processed set this value to 1 00850 uint32_t crc_error_ctx;//crc_error_ctx should always be the last member in this struct 00851 #endif 00852 } mbed_error_ctx; 00853 00854 /** To generate a fatal compile-time error, you can use the pre-processor #error directive. 00855 * 00856 * @param format C string that contains data stream to be printed. 00857 * Code snippets below show valid format. 00858 * 00859 * @code 00860 * #error "That shouldn't have happened!" 00861 * @endcode 00862 * 00863 * If the compiler evaluates this line, it will report the error and stop the compile. 00864 * 00865 * For example, you could use this to check some user-defined compile-time variables: 00866 * 00867 * @code 00868 * #define NUM_PORTS 7 00869 * #if (NUM_PORTS > 4) 00870 * #error "NUM_PORTS must be less than 4" 00871 * #endif 00872 * @endcode 00873 * 00874 * Reporting Run-Time Errors: 00875 * To generate a fatal run-time error, you can use the mbed error() function. 00876 * 00877 * @code 00878 * error("That shouldn't have happened!"); 00879 * @endcode 00880 * 00881 * If the mbed running the program executes this function, it will print the 00882 * message via the USB serial port, and then die with the blue lights of death! 00883 * 00884 * The message can use printf-style formatting, so you can report variables in the 00885 * message too. For example, you could use this to check a run-time condition: 00886 * 00887 * @code 00888 * if(x >= 5) { 00889 * error("expected x to be less than 5, but got %d", x); 00890 * } 00891 * @endcode 00892 * 00893 * 00894 */ 00895 00896 MBED_NORETURN void error(const char *format, ...) MBED_PRINTF(1, 2); 00897 00898 /** 00899 * Call this Macro to generate a mbed_error_status_t value for a System error 00900 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types. 00901 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes. 00902 * 00903 * @code 00904 * 00905 * mbed_error_status_t driver_error = MBED_MAKE_SYSTEM_ERROR( MODULE_DRIVER_USB, MBED_ERROR_CODE_INITIALIZATION_FAILED ) 00906 * 00907 * @endcode 00908 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_SYSTEM 00909 * 00910 */ 00911 #define MBED_MAKE_SYSTEM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_SYSTEM, module, error_code) 00912 00913 /** 00914 * Call this Macro to generate a mbed_error_status_t value for a Custom error 00915 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types. 00916 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes. 00917 * 00918 * @code 00919 * 00920 * mbed_error_status_t custom_error = MBED_MAKE_CUSTOM_ERROR( MBED_MODULE_APPLICATION, 0xDEAD//16-bit custom error code ) 00921 * 00922 * @endcode 00923 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_CUSTOM 00924 * 00925 */ 00926 #define MBED_MAKE_CUSTOM_ERROR(module, error_code) MAKE_MBED_ERROR(MBED_ERROR_TYPE_CUSTOM, module, error_code) 00927 00928 /** 00929 * Call this Macro to generate a mbed_error_status_t value for a System error 00930 * @param module Module generating the error code. If its unknown, pass MBED_MODULE_UNKNOWN. See mbed_module_type_t for module types. 00931 * @param error_code The mbed_error_code_t code to be used in generating the mbed_error_status_t. See mbed_error_code_t for error codes. 00932 * 00933 * @code 00934 * 00935 * mbed_error_status_t new_error = MBED_MAKE_ERROR( MODULE_DRIVER_USB, MBED_ERROR_INITIALIZATION_FAILED ) 00936 * 00937 * @endcode 00938 * @note This macro generate mbed_error_status_t-es with error type set to MBED_ERROR_TYPE_SYSTEM 00939 * 00940 */ 00941 #define MBED_MAKE_ERROR(module, error_code) MBED_MAKE_SYSTEM_ERROR(module, error_code) 00942 00943 /** 00944 * Callback/Error hook function prototype. Applications needing a callback when an error is reported can use mbed_set_error_hook function 00945 * to register a callback/error hook function using the following prototype. When an error happens in the system error handling 00946 * implementation will invoke this callback with the mbed_error_status_t reported and the error context at the time of error. 00947 * @param error_ctx Error context structure associated with this error. 00948 * @return void 00949 * 00950 */ 00951 typedef void (*mbed_error_hook_t)(const mbed_error_ctx *error_ctx); 00952 00953 00954 /** 00955 * Callback function for reporting error context during boot up. When MbedOS error handling system detects a fatal error 00956 * it will auto-reboot the system(if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled) after capturing the 00957 * error info in special crash data RAM region. Once rebooted, MbedOS initialization routines will call this function with a pointer to 00958 * the captured mbed_error_ctx structure. If application implementation needs to receive this callback, mbed_error_reboot_callback 00959 * function should be overridden with custom implementation. By default it's defined as a WEAK function in mbed_error.c. 00960 * Note that this callback will be invoked before the system starts executing main() function. So the implementation of 00961 * the callback should be aware any resource limitations/availability of resources which are yet to be initialized by application main(). 00962 * 00963 * @param error_ctx Error context structure associated with this error. 00964 * @return void 00965 * 00966 */ 00967 void mbed_error_reboot_callback(mbed_error_ctx *error_context); 00968 00969 /** 00970 * Initialize error handling system, this is called by the mbed-os boot sequence. This is not required to be called by Application unless the boot sequence is overridden by the system implementation. 00971 * NOTE: If MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED is enabled and if the current reboot count exceeds MBED_CONF_PLATFORM_ERROR_REBOOT_MAX the system will halt when this function is called, 00972 * and in such cases the caller will not get the control back. Also note that calling this function may trigger mbed_error_reboot_callback() if application side overides mbed_error_reboot_callback(). 00973 * @return MBED_SUCCESS on success. 00974 * 00975 */ 00976 00977 mbed_error_status_t mbed_error_initialize(void); 00978 00979 /** 00980 * Call this function to retrieve the error context after a fatal error which triggered a system reboot. The function retrieves the error context stored in crash-report ram area which is preserved over reboot. 00981 * @param error_info Pointer to mbed_error_ctx struct allocated by the caller. This is the mbed_error_ctx info captured as part of the fatal error which triggered the reboot. 00982 * @return 0 or MBED_SUCCESS on success. 00983 * MBED_ERROR_INVALID_ARGUMENT in case of invalid error_info pointer 00984 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system 00985 * 00986 */ 00987 mbed_error_status_t mbed_get_reboot_error_info(mbed_error_ctx *error_info); 00988 00989 /** 00990 * Calling this function resets the current reboot context captured by the system(stored in special crash data RAM region). 00991 * @return MBED_SUCCESS on success. 00992 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system 00993 */ 00994 mbed_error_status_t mbed_reset_reboot_error_info(void); 00995 00996 /** 00997 * Calling this function resets the current reboot count stored as part of error context captured in special crash data RAM region. 00998 * The function will also update the CRC value stored as part of error context accordingly. 00999 * @return MBED_SUCCESS on success. 01000 * MBED_ERROR_ITEM_NOT_FOUND if no reboot context is currently captured by the system 01001 */ 01002 mbed_error_status_t mbed_reset_reboot_count(void); 01003 01004 /** 01005 * Call this function to set a system error/warning. This function will log the error status with the context info and return to caller. 01006 * 01007 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values). 01008 * @param error_msg The error message to be printed out to STDIO/Serial. 01009 * @param error_value Value associated with the error status. This would depend on error code/error scenario. 01010 * @param filename Name of the source file originating the error( Most callers can pass __FILE__ here ). 01011 * @param line_number The line number of the source file originating the error( Most callers can pass __LINE__ here ) . 01012 * @return 0 or MBED_SUCCESS. 01013 * MBED_ERROR_INVALID_ARGUMENT if called with invalid error status/codes 01014 * 01015 * @code 01016 * 01017 * mbed_error( ERROR_OUT_OF_MEMORY, "Out of memory error", 0, __FILE__, __LINE__ ) 01018 * 01019 * @endcode 01020 * 01021 * @note See MBED_WARNING/MBED_ERROR macros which provides a wrapper on this API 01022 */ 01023 mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number); 01024 01025 /** 01026 * Returns the first system error reported. 01027 * @return mbed_error_status_t code logged for the first error or MBED_SUCCESS if no errors are logged. 01028 * 01029 */ 01030 mbed_error_status_t mbed_get_first_error(void); 01031 01032 /** 01033 * Returns the most recent system error reported. 01034 * @return mbed_error_status_t code logged for the last error or MBED_SUCCESS if no errors are logged. 01035 * 01036 */ 01037 mbed_error_status_t mbed_get_last_error(void); 01038 01039 /** 01040 * Returns the number of system errors reported after boot. 01041 * @return int Number of errors reported. 01042 * 01043 */ 01044 int mbed_get_error_count(void); 01045 01046 /** 01047 * Returns whether we are processing a fatal mbed error. 01048 * @return bool Whether a fatal error has occurred. 01049 * 01050 */ 01051 bool mbed_get_error_in_progress(void); 01052 01053 /** 01054 * 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. 01055 * 01056 * @param error_status mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values). 01057 * @param error_msg The error message to be printed out to STDIO/Serial. 01058 * @param error_value Value associated with the error status. This would depend on error code/error scenario. 01059 * @param filename Name of the source file originating the error( Most callers can pass __FILE__ here ). 01060 * @param line_number The line number of the source file originating the error( Most callers can pass __LINE__ here ) . 01061 * @return Does not return. 01062 * 01063 * @code 01064 * 01065 * mbed_error( MBED_ERROR_PROHIBITED_OPERATION, "Prohibited operation tried", 0, __FILE__, __LINE__ ) 01066 * 01067 * @endcode 01068 * 01069 * @note See MBED_WARNING/MBED_ERROR macros which provides a wrapper on this API 01070 */ 01071 MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number); 01072 01073 /** 01074 * Registers an application defined error callback with the error handling system. 01075 * This function will be called with error context info whenever system handles a mbed_error/mbed_warning call 01076 * NOTE: This function should be implemented for re-entrancy as multiple threads may invoke mbed_error which may cause error hook to be called. 01077 * @param custom_error_hook mbed_error_status_t status to be set(See mbed_error_status_t enum above for available error status values). 01078 * @return 0 or MBED_SUCCESS on success. 01079 * MBED_ERROR_INVALID_ARGUMENT in case of NULL for custom_error_hook 01080 * 01081 * @code 01082 * 01083 * mbed_error_status_t my_custom_error_hook(mbed_error_status_t error_status, const mbed_error_ctx *error_ctx) { 01084 * //Do something with the error_status or error_ctx 01085 * } 01086 * 01087 * mbed_set_error_hook( my_custom_error_hook ) 01088 * 01089 * @endcode 01090 * @note The erro hook function implementation should be re-entrant. 01091 * 01092 */ 01093 mbed_error_status_t mbed_set_error_hook(mbed_error_hook_t custom_error_hook); 01094 01095 /** 01096 * Reads the first error context information captured. 01097 * @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. 01098 * @return 0 or MBED_SUCCESS on success. 01099 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index 01100 * 01101 */ 01102 mbed_error_status_t mbed_get_first_error_info(mbed_error_ctx *error_info); 01103 01104 /** 01105 * Reads the last error context information captured. 01106 * @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. 01107 * @return 0 or MBED_ERROR_SUCCESS on success. 01108 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index 01109 * 01110 */ 01111 mbed_error_status_t mbed_get_last_error_info(mbed_error_ctx *error_info); 01112 01113 /** 01114 * Clears the last error, first error, error count and all entries in the error history. 01115 * @return 0 or MBED_SUCCESS on success. 01116 * 01117 */ 01118 mbed_error_status_t mbed_clear_all_errors(void); 01119 01120 /** 01121 * Generates a mbed_error_status_t value based on passed in values for type, module and error code. 01122 * @param error_type Error type based on mbed_error_type_t enum. 01123 * @param module Module type based on mbed_module_type_t enum. 01124 * @param error_code Error codes defined by mbed_error_code_t enum 01125 * @return 0 or MBED_ERROR_SUCCESS on success. 01126 * 01127 */ 01128 mbed_error_status_t mbed_make_error(mbed_error_type_t error_type, mbed_module_type_t module, mbed_error_code_t error_code); 01129 01130 /** 01131 * 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. 01132 * @return Current number of entries in the error history. 01133 * 01134 */ 01135 int mbed_get_error_hist_count(void); 01136 01137 /** 01138 * Reads the error context information for a specific error from error history, specified by the index. 01139 * 01140 * @param index index of the error context entry in the history to be retrieved.\n 01141 * The number of entries in the error history is configured during build and the max index depends on max depth of error history.\n 01142 * 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 01143 * @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. 01144 * @return 0 or MBED_SUCCESS on success. 01145 * MBED_ERROR_INVALID_ARGUMENT in case of invalid index 01146 * 01147 */ 01148 mbed_error_status_t mbed_get_error_hist_info(int index, mbed_error_ctx *error_info); 01149 01150 /** 01151 * Saves the error history information to a file 01152 * 01153 * @param path path to the file in the filesystem 01154 * @return 0 or MBED_ERROR_SUCCESS on success. 01155 * MBED_ERROR_WRITE_FAILED if writing to file failed 01156 * MBED_ERROR_INVALID_ARGUMENT if path is not valid 01157 * 01158 * @note Filesystem support is required in order for this function to work. 01159 * 01160 */ 01161 mbed_error_status_t mbed_save_error_hist(const char *path); 01162 01163 #ifdef __cplusplus 01164 } 01165 #endif 01166 01167 #endif 01168 01169 /** @}*/ 01170 /** @}*/ 01171 01172
Generated on Tue Jul 12 2022 13:54:33 by
