96 lines
2.4 KiB
C
96 lines
2.4 KiB
C
#ifndef LIBDI_INCLUDE_DI_DEVICE_ERROR_H_
|
|
#define LIBDI_INCLUDE_DI_DEVICE_ERROR_H_
|
|
|
|
#include <di/types.h>
|
|
|
|
// Device error list size
|
|
#define DI_DEVICE_ERROR_LIST_SIZE 8U
|
|
|
|
typedef struct mpack_writer_t mpack_writer_t;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* Check if one or more device errors are set
|
|
* @retval true if one or more errors are set, false otherwise
|
|
*/
|
|
bool di_device_error_is_set(void);
|
|
|
|
/**
|
|
* Check if one or more warnings are set
|
|
* @retval true if one or more warnings are set, false otherwise
|
|
*/
|
|
bool di_device_error_warning_is_set(void);
|
|
|
|
/**
|
|
* Set or increment device error. The only valid error codes ranges are:
|
|
* - Generic (1-255)
|
|
* - Firmware (1024-2999)
|
|
* - CAN Protocol (3000-3050)
|
|
* - Firmware Warning (2001024-2002999)
|
|
* @param error Error code to set or increment
|
|
* @retval DNOK Error is set or incremented
|
|
* @retval DNE_PARAM Error is not within valid range
|
|
* @retval DNE_NOMEM No space left to store error
|
|
*/
|
|
di_errno_t di_device_error_set(const di_errno_t error);
|
|
|
|
/**
|
|
* Check if specific device error code is set
|
|
* @param error Specific error
|
|
* @retval true Device error is set
|
|
* @retval false Device error is not set
|
|
*/
|
|
bool di_device_error_is_specific_set(di_errno_t error);
|
|
|
|
/**
|
|
* Unset device error code
|
|
* @param error The specific error to unset
|
|
* @retval true Device error is reset
|
|
* @retval false No such device error known
|
|
*/
|
|
void di_device_error_unset(const di_errno_t error);
|
|
|
|
/**
|
|
* Reset all device errors and warnings (this is called also at di_device_init)
|
|
*/
|
|
void di_device_error_reset_all(void);
|
|
|
|
/**
|
|
* Reset all device errors
|
|
*/
|
|
void di_device_error_reset_all_errors(void);
|
|
|
|
/**
|
|
* Reset all device warnings
|
|
*/
|
|
void di_device_error_reset_all_warnings(void);
|
|
|
|
/**
|
|
* Write all current errors in RPC message result format
|
|
* as Array of di_error items.
|
|
* @param writer MessagePack writer
|
|
* @retval DNOK when write was successful, !DNOK otherwise
|
|
*/
|
|
di_errno_t di_device_error_list_write_rpc_result_msg(mpack_writer_t *writer);
|
|
|
|
/**
|
|
* Get the device error list size (maximum amount of errors can be stored)
|
|
*/
|
|
size_t di_device_error_list_size(void);
|
|
|
|
/**
|
|
* Copy the device raised errors list.
|
|
* @param errors[out] Destination errors list
|
|
* @return Amount of raised errors copied.
|
|
*/
|
|
size_t di_device_error_list_copy(di_errno_t errors[DI_DEVICE_ERROR_LIST_SIZE]);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* LIBDI_INCLUDE_DI_DEVICE_ERROR_H_ */
|