From 52c72383f149ec97bc0f125e77512f78e0c5e241 Mon Sep 17 00:00:00 2001 From: Audrey Diacre Date: Wed, 4 Jan 2012 16:44:40 +0000 Subject: [PATCH] pn53x_build_frame() function returns now 0 on success and libnfc error code on failure. --- libnfc/chips/pn53x.c | 6 +++--- libnfc/chips/pn53x.h | 2 +- libnfc/drivers/arygon.c | 2 +- libnfc/drivers/pn532_uart.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index b7678d4..2f504e5 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -2465,7 +2465,7 @@ pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, cons * @param pbtData payload (bytes array) of the frame, will become PD0, ..., PDn in PN53x frame * @note The first byte of pbtData is the Command Code (CC) */ -bool +int pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, const size_t szData) { if (szData <= PN53x_NORMAL_FRAME__DATA_MAX_LEN) { @@ -2517,9 +2517,9 @@ pn53x_build_frame (uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, (*pszFrame) = szData + PN53x_EXTENDED_FRAME__OVERHEAD; } else { log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "We can't send more than %d bytes in a raw (requested: %zd)", PN53x_EXTENDED_FRAME__DATA_MAX_LEN, szData); - return false; + return NFC_ECHIP; } - return true; + return NFC_SUCCESS; } pn53x_modulation pn53x_nm_to_pm(const nfc_modulation nm) diff --git a/libnfc/chips/pn53x.h b/libnfc/chips/pn53x.h index 955dfc6..3f18c11 100644 --- a/libnfc/chips/pn53x.h +++ b/libnfc/chips/pn53x.h @@ -353,7 +353,7 @@ int pn53x_RFConfiguration__MaxRetries (struct nfc_device *pnd, const uint8_t // Misc 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); +int 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); void pn53x_data_free (struct nfc_device *pnd); diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index f678e69..011bb57 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -319,7 +319,7 @@ arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, return false; } - if (!pn53x_build_frame (abtFrame + 1, &szFrame, pbtData, szData)) { + if (pn53x_build_frame (abtFrame + 1, &szFrame, pbtData, szData) < 0) { pnd->last_error = NFC_EINVARG; return false; } diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index 6c018cf..4b1049e 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -320,7 +320,7 @@ pn532_uart_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData, i uint8_t abtFrame[PN532_BUFFER_LEN] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff" size_t szFrame = 0; - if (!pn53x_build_frame (abtFrame, &szFrame, pbtData, szData)) { + if (pn53x_build_frame (abtFrame, &szFrame, pbtData, szData) < 0) { pnd->last_error = NFC_EINVARG; return false; }