From e87241184aa41c31b50d64bc47b34113f935f41b Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Wed, 4 Jan 2012 16:32:16 +0000 Subject: [PATCH] pn53x_check_ack_frame() and pn53x_check_error_frame() functions return now 0 on success and libnfc error code on failure. --- libnfc/chips/pn53x.c | 12 ++++++------ libnfc/chips/pn53x.h | 4 ++-- libnfc/drivers/arygon.c | 2 +- libnfc/drivers/pn532_uart.c | 2 +- libnfc/drivers/pn53x_usb.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index eaccbeb..b7678d4 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -2432,31 +2432,31 @@ pn53x_TgInitAsTarget (struct nfc_device *pnd, pn53x_target_mode ptm, return NFC_SUCCESS; } -bool +int pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen) { if (szRxFrameLen >= sizeof (pn53x_ack_frame)) { if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) { log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x ACKed"); - return true; + return NFC_SUCCESS; } } pnd->last_error = NFC_EIO; log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unexpected PN53x reply!"); - return false; + return pnd->last_error; } -bool +int pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen) { if (szRxFrameLen >= sizeof (pn53x_error_frame)) { if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) { log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x sent an error frame"); pnd->last_error = NFC_EIO; - return false; + return pnd->last_error; } } - return true; + return NFC_SUCCESS; } /** diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index f8bac33..955dfc6 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -351,8 +351,8 @@ int pn53x_RFConfiguration__MaxRtyCOM (struct nfc_device *pnd, const uint8_t M int pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t MxRtyATR, const uint8_t MxRtyPSL, const uint8_t MxRtyPassiveActivation); // Misc -bool pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen); -bool pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen); +int pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen); +int pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const size_t szRxFrameLen); bool pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData); void pn53x_data_new (struct nfc_device *pnd, const struct pn53x_io *io); diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index ec20056..f678e69 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -339,7 +339,7 @@ arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, return false; } - if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf))) { + if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) { // The PN53x is running the sent command } else if (0 == memcmp(arygon_error_unknown_mode, abtRxBuf, sizeof(abtRxBuf))) { log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Bad frame format." ); diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index ce3147d..6c018cf 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -340,7 +340,7 @@ pn532_uart_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, i return false; } - if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf))) { + if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) { // The PN53x is running the sent command } else { return false; diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index 1ec7524..f789034 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -529,7 +529,7 @@ pn53x_usb_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, co return false; } - if (pn53x_check_ack_frame (pnd, abtRxBuf, res)) { + if (pn53x_check_ack_frame (pnd, abtRxBuf, res) == 0) { // The PN53x is running the sent command } else { // For some reasons (eg. send another command while a previous one is