Error handling¶
Error logging and tracking.
All logged errors in the system must be unique. The error logging and tracking module keeps track of the number of each error and provides the timestamp of the last occurance.
Typedefs
-
typedef struct sc_error_data
sc_error_data
Representation of a single error type. Each error must be unique in the system.
Functions
-
bool
sc_error_register
(char *name, sc_error_data *data, uint8_t data_size, uint8_t *module) Register errors for a module.
- Parameters
name
: Name of the module.data
: An array of errors for the module. The error struct fields must be initialized to zero except for the message that must be the name of the error.data_size
: Number of error elements in the data array.module
: The index number of the module. This must be called when logging the actual errors. This is only set if the registration succeeds.
- Return Value
true
: if successful.false
: if failed.
-
void
sc_error_log
(uint8_t module, uint8_t error) Log an error.
The module must be acquired first by calling sc_error_register.
- Parameters
module
: Index of the module.error
: Index of the error in the module’s error list passed to sc_error_register.
- Return Value
true
: if successful.false
: if failed.
-
void
sc_error_log_int
(uint8_t module, uint8_t error, uint32_t param) Log an error with one integer parameter.
Same as sc_error_log but with additional integered parameter. The module must be acquired first by calling sc_error_register.
- Parameters
module
: Index of the module.error
: Index of the error in the module’s error list passed to sc_error_register.param
: Integer variable to be printed as a part of the error message.
- Return Value
true
: if successful.false
: if failed.
-
struct
sc_error_data
- #include <sc_error.h>
Representation of a single error type. Each error must be unique in the system.
Public Members
-
uint32_t
count
-
int64_t
ts
-
char *
message
-
uint32_t