KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
errorcode.h File Reference

This module is responsible for distributing error codes. More...

Go to the source code of this file.

Macros

#define CAT(A, B)   A ## B
 
#define ERROR_WITH_DESCR
 When defined includes the error description in the compilation unit.
 
#define ERROR(CODE,...)   CODE, CODE ## _DESCR, 0
 Expands an error code to an error code with a description (if ERROR_W_DESCR is declared). More...
 
#define ERROR_INFO(CODE, INFO)   CODE, CODE ## _DESCR " (" INFO ")", 0
 
#define ERROR_CTX(CODE,...)   CODE, CODE ## _DESCR, _logModInfo.name
 
#define ERROR_CTX_INFO(CODE, INFO)   CODE, CODE ## _DESCR " (" INFO ")", _logModInfo.name
 
#define E_NONE   0x00
 Zero is no error.
 
#define E_NONE_DESCR   "No error"
 
#define E_UNKNOWN   0x01
 Generic error: Unknown error.
 
#define E_UNKNOWN_DESCR   "Unknown error"
 
#define E_TIMEOUT   0x02
 Generic error: Timeout error.
 
#define E_TIMEOUT_DESCR   "Timeout"
 
#define E_INVSTATE   0x03
 Generic error: Module is in a state in which. More...
 
#define E_INVSTATE_DESCR   "Invalid state"
 
#define E_OUTOFMEMORY   0x04
 Generic error: There is no more memory. More...
 
#define E_OUTOFMEMORY_DESCR   "Out of memory"
 
#define E_INVARGUMENT   0x05
 Generic error: invalid argument.
 
#define E_INVARGUMENT_DESCR   "Invalid argument"
 
#define E_NOTSUPPORTED   0x06
 Generic error: not supported.
 
#define E_NOTSUPPORTED_DESCR   "Not supported"
 
#define E_NOTIMPLEMENTED   0x07
 Generic error: not implemented.
 
#define E_NOTIMPLEMENTED_DESCR   "Not implemented"
 
#define E_NOTFOUND   0x08
 Generic error: not found (ID or resource. More...
 
#define E_NOTFOUND_DESCR   "Element not found"
 
#define E_PLATFORM   0x010000
 Error codes platform offset.
 
#define E_SUART   ( E_PLATFORM + 0x1100 )
 WhiteRabbit Simple UART.
 
#define E_I2C   ( E_PLATFORM + 0x1200 )
 OpenCores I2C.
 
#define E_SPI   ( E_PLATFORM + 0x1300 )
 OpenCores SPI.
 
#define E_SDB   ( E_PLATFORM + 0x1400 )
 Self Describing Bus.
 
#define E_DPB   ( E_PLATFORM + 0x2100 )
 DigitPicco Basic.
 
#define E_SFLASH   ( E_PLATFORM + 0x2200 )
 Serial flash driver error.
 
#define E_AHRS   ( E_PLATFORM + 0x2300 )
 AHRS.
 
#define E_PRMS   ( E_I2C + 0x10 )
 OpenCores I2C.
 
#define E_SCHD   ( E_PLATFORM + 0x0100 )
 Scheduler.
 
#define E_MSG   ( E_PLATFORM + 0x0200 )
 Error in message processing.
 
#define E_UPD   ( E_PLATFORM + 0x0300 )
 Update module.
 
#define E_PREC   ( E_PLATFORM + 0x0400 )
 Persistent Record module.
 
#define E_WRX   ( E_PLATFORM + 0x0500 )
 WhiteRabbit eXchange'.
 
#define E_NET   ( E_PLATFORM + 0x0600 )
 Networking.
 
#define E_BLOCK   ( E_PLATFORM + 0x0700 )
 Block Store.
 
#define E_OCTO   ( E_PLATFORM + 0x8700 )
 Octopus board module.
 
#define E_APP   0x020000
 Error codes application offset.
 

Detailed Description

This module is responsible for distributing error codes.

It does not contain all error codes itself.

To add error codes, first add a module entry with a short name. Each module has 256 possible errors:

#define E_MYMOD ( E_PLAFORM + 0x0700 )

Note that there should be no other modules with the same error code range.

Then in your header file define each error with the specified module offset, in this case E_MYMOD. Note that you have 256 possible codes, so never go beyond 0xFF. Also a text-description should be provided using the '_DESCR' postfix.

#define E_MYMOD_TIMEOUT ( E_MYMOD + 0x01 ) ///< MyMod timed out.
#define E_MYMOD_TIMEOUT_DESCR "MyMod transmission timeout"

When creating an error in the err module, do this as follows:

// ...
if (t > tout) {
errSet(ERROR(E_MYMOD_TIMEOUT));
return false;
}
// ...

When ERROR_W_DESCR is enabled, all error codes will also create a text representation of this error, which will be displayed with errPrint or can be retrieved with errGetStr(). If ERROR_W_DESCR is not defined, all descriptions will not be included into the compile unit and only the error code is displayed.

Definition in file errorcode.h.

Macro Definition Documentation

#define E_INVSTATE   0x03

Generic error: Module is in a state in which.

it can not service your request.

Definition at line 103 of file errorcode.h.

#define E_NOTFOUND   0x08

Generic error: not found (ID or resource.

does not exist)

Definition at line 121 of file errorcode.h.

#define E_OUTOFMEMORY   0x04

Generic error: There is no more memory.

available for this operation.

Definition at line 107 of file errorcode.h.

#define ERROR (   CODE,
  ... 
)    CODE, CODE ## _DESCR, 0

Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).

Used with errSet(), like this:

errSet(ERROR(E_MYMOD_TIMEOUT));
Parameters
CODEThe E_* constant.