From 8fef257d16a934cd8f2e61abf5326562a7f461c2 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Sun, 8 Aug 2010 15:25:06 +0000 Subject: [PATCH] Also use pn53x_transceive_callback() in the arygon driver. While here, remove unneeded header in pn532_uart.c. --- libnfc/drivers/arygon.c | 27 ++++----------------------- libnfc/drivers/pn532_uart.c | 1 - 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index d3261d8..3f421da 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -219,9 +219,6 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx size_t szRxBufLen = BUFFER_LENGTH; size_t szPos; - const byte_t pn53x_ack_frame[] = { 0x00,0x00,0xff,0x00,0xff,0x00 }; - const byte_t pn53x_nack_frame[] = { 0x00,0x00,0xff,0xff,0x00,0x00 }; - // Packet length = data length (len) + checksum (1) + end of stream marker (1) abtTxBuf[4] = szTxLen; // Packet length checksum @@ -247,6 +244,7 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx return false; } + szRxBufLen = 6; if (!uart_receive((serial_port)pnd->nds,abtRxBuf,&szRxBufLen)) { ERR("%s", "Unable to receive data. (RX)"); return false; @@ -256,31 +254,14 @@ bool arygon_transceive(nfc_device_t* pnd, const byte_t* pbtTx, const size_t szTx PRINT_HEX("RX", abtRxBuf,szRxBufLen); #endif - if(szRxBufLen >= sizeof(pn53x_ack_frame)) { + if (!pn53x_transceive_callback(pnd, abtRxBuf, szRxBufLen)) + return false; - // Check if PN53x reply ACK - if(0!=memcmp(pn53x_ack_frame, abtRxBuf, sizeof(pn53x_ack_frame))) { - DBG("%s", "PN53x doesn't respond ACK frame."); - if (0==memcmp(pn53x_nack_frame, abtRxBuf, sizeof(pn53x_nack_frame))) { - ERR("%s", "PN53x reply NACK frame."); - // FIXME Handle NACK frame i.e. resend frame, PN53x doesn't received it correctly - } - return false; - } + szRxBufLen = BUFFER_LENGTH; - szRxBufLen -= sizeof(pn53x_ack_frame); - if(szRxBufLen) { - memmove(abtRxBuf, abtRxBuf+sizeof(pn53x_ack_frame), szRxBufLen); - } - } - - if(szRxBufLen == 0) { - // There was no more data than ACK frame, we need to wait next frame - DBG("%s", "There was no more data than ACK frame, we need to wait next frame"); while (!uart_receive((serial_port)pnd->nds,abtRxBuf,&szRxBufLen)) { delay_ms(10); } - } #ifdef DEBUG PRINT_HEX("RX", abtRxBuf,szRxBufLen); diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index 64e95f2..a9f4905 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -27,7 +27,6 @@ #endif // HAVE_CONFIG_H #include "../drivers.h" -#include "../chips/pn53x.h" #include #include