xyControl  0.1
Quadrotor Flight Controller on AVR Basis
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Files | Macros | Enumerations | Functions
Error Reporting

Error reporting with human readable strings. More...

Files

file  error.h
 Global listing of different error conditions.
 

Macros

#define CHECKERROR(x)   if(x!=SUCCESS){return x;}
 Check an Error Code. More...
 
#define REPORTERROR(x)
 Report an error, if it occured. More...
 

Enumerations

enum  Error {
  SUCCESS = 0, TWI_NO_ANSWER, TWI_WRITE_ERROR, MALLOC_FAIL,
  ERROR, ARGUMENT_ERROR
}
 Error Conditions. More...
 

Functions

char * getErrorString (Error e)
 Returns a human-readable error description. More...
 

Detailed Description

Error reporting with human readable strings.

Macro Definition Documentation

#define CHECKERROR (   x)    if(x!=SUCCESS){return x;}

Check an Error Code.

Return it if an error occured.

Definition at line 56 of file error.h.

Referenced by orientationInit(), and orientationTask().

#define REPORTERROR (   x)
Value:
{ \
if (x != SUCCESS) { \
char *s = getErrorString(x); \
printf("Error: %s\n", s); \
free(s); \
} \
}

Report an error, if it occured.

Using printf()

Examples:
uartFlight.c.

Definition at line 59 of file error.h.

Enumeration Type Documentation

enum Error

Error Conditions.

Enumerator
SUCCESS 

No Error.

TWI_NO_ANSWER 

No answer from TWI Slave.

TWI_WRITE_ERROR 

Error while writing to TWI Slave.

MALLOC_FAIL 

Malloc failed.

ERROR 

General Error.

ARGUMENT_ERROR 

Invalid arguments.

Definition at line 46 of file error.h.

46  {
47  SUCCESS = 0,
50  MALLOC_FAIL,
51  ERROR,
53 } Error;

Function Documentation

char* getErrorString ( Error  e)

Returns a human-readable error description.

Free the string after use!

Definition at line 58 of file error.c.

References errorTable.

58  {
59  char *buff = (char *)malloc(strlen_P((PGM_P)pgm_read_word(&(errorTable[e]))));
60  if (buff == NULL) {
61  return NULL;
62  }
63  strcpy_P(buff, (PGM_P)pgm_read_word(&(errorTable[e])));
64  return buff;
65 }