Second part of error handling.
- Define two sets of DE<FOOBAR> macros: the first one for 'generic' errors which could be encountered regardless of the NFC device the library is acting with (0xX000), and ont set for device-dependant errors (0x0X00). - Make some more functions accept a nfc_device_t* as first argument to have access to the iLastError; - Reset errors when entering public API functions; - Save errors when applicable; - Distinguish system-level errors (e.g. I/O error) and operational errors (the PCD returns an unexpected value); - Minor tweaks. Update issue 65 Status: Feedback New review: Owner: rconty@il4p.fr Cc: rtartiere@il4p.fr Summary: Review the error-handling code. Branch: /branches/libnfc-error-handling For this development, a strong emphasis has been set on making changes that will not go through our way on the way to libnfc-1.6+. For this reason, some constructs are not natural (e.g. error codes defined in two different places), please keep this in mind when reviewing.
This commit is contained in:
parent
d7e0b926ac
commit
08eb21aa9d
9 changed files with 166 additions and 31 deletions
|
|
@ -69,7 +69,14 @@ typedef struct {
|
|||
bool bPar;
|
||||
/** The last tx bits setting, we need to reset this if it does not apply anymore */
|
||||
uint8_t ui8TxBits;
|
||||
/** Last error reported by the PCD / encountered by the PCD driver */
|
||||
/** Last error reported by the PCD / encountered by the PCD driver
|
||||
* MSB LSB
|
||||
* | 00 | 00 |
|
||||
* || ||
|
||||
* || ++----- Chip-level error (as reported by the PCD)
|
||||
* |+---------- Driver-level specific error
|
||||
* +----------- Driver-level general error (common to all drivers)
|
||||
*/
|
||||
int iLastError;
|
||||
} nfc_device_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,11 @@ NFC_EXPORT void iso14443a_crc(byte_t* pbtData, size_t szLen, byte_t* pbtCrc);
|
|||
NFC_EXPORT void append_iso14443a_crc(byte_t* pbtData, size_t szLen);
|
||||
NFC_EXPORT const char* nfc_version(void);
|
||||
|
||||
/* Common device-level errors */
|
||||
#define DEIO 0x1000 /* Input/output error */
|
||||
#define DEINVAL 0x2000 /* Invalid argument */
|
||||
#define DETIMEOUT 0x3000 /* Operation timeout */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue