Infineon Error Library
This library offers utilities to create and decode C style
ifx_status_t error codes.
In complex library chains it is often difficult to track exactly where errors come from. All Infineon host software libraries therefore encode their errors according to the following schema:
Bits |
Information |
|---|---|
|
Error indicator set to |
|
Library identifier (e.g. |
|
Module identifier (e.g. |
|
Function identifier in module (e.g. |
|
Function-specific error reason (e.g. |
A return value of 0x811003FE would therefore indicate:
Bit
31is set -> error.Bits
30-24are set to0x01->hsw-apdulibraryBits
23-16are set to0x10->apdu-responsemoduleBits
15-8are set to0x03->ifx_apdu_response_decodefunctionBits
7-0are set to0xFE-> Out of memory
Example
#include "infineon/ifx-error.h"
#include "infineon/ifx-apdu.h"
ifx_status_t error_code = IFX_ERROR(LIB_APDU, IFX_APDU_ENCODE, IFX_OUT_OF_MEMORY);
if (ifx_error_check(error_code))
{
switch(ifx_error_get_module(error_code))
{
case LIB_APDU:
switch (ifx_error_get_function(error_code))
{
case IFX_APDU_ENCODE:
switch (ifx_error_get_reason(error_code))
{
case IFX_OUT_OF_MEMORY:
printf("Out of memory during APDU encoding\n");
break;
default:
printf("Unknown error during APDU encoding\n");
break;
}
break;
default:
printf("Error in unknown APDU function\n");
break;
}
break;
default:
printf("Error in unknown module\n");
break;
}
}
Reusable Error Reasons
This library offers a set of reusable error reasons similar to standard exceptions in other languages.
The following table gives an overview of these values and a quick description for each.
Value |
Name |
Description |
|---|---|---|
|
|
Error without any further information |
|
|
Could not allocate memory |
|
|
Illegal argument given to function call |
|
|
Too little data available (e.g. in decoding functions) |
|
|
Program (currently) in invalid state |
|
|
Error that should have already been caught by the programmer occurred |