From 805d738b24dfd0fbbdd301acfe7adbb5b0ff1e57 Mon Sep 17 00:00:00 2001 From: Romuald Conty Date: Fri, 6 May 2011 15:03:08 +0000 Subject: [PATCH] Implement PN53x extended information frames with USB devices. (Fixes Issue 158) --- libnfc/drivers/arygon.c | 2 +- libnfc/drivers/pn532_uart.c | 1 + libnfc/drivers/pn53x_usb.c | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index 8012966..a39d3bd 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -324,7 +324,7 @@ arygon_tama_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLe return -1; } else if ((0xff == abtRxBuf[3]) && (0xff == abtRxBuf[4])) { // Extended frame - // FIXME: Code this + // ARYGON devices does not support extended frame sending abort (); } else { // Normal frame diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index f178202..29f6786 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -309,6 +309,7 @@ pn532_uart_receive (nfc_device_t * pnd, byte_t * pbtData, const size_t szDataLen } else if ((0xff == abtRxBuf[3]) && (0xff == abtRxBuf[4])) { // Extended frame pnd->iLastError = uart_receive (DRIVER_DATA(pnd)->port, abtRxBuf, 3, 0); + if (pnd->iLastError) return -1; // (abtRxBuf[0] << 8) + abtRxBuf[1] (LEN) include TFI + (CC+1) len = (abtRxBuf[0] << 8) + abtRxBuf[1] - 2; diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index 6bf4ccf..564f831 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -461,8 +461,16 @@ read: return -1; } else if ((0xff == abtRxBuf[offset]) && (0xff == abtRxBuf[offset + 1])) { // Extended frame - // FIXME: Code this - abort (); + offset += 2; + + // (abtRxBuf[offset] << 8) + abtRxBuf[offset + 1] (LEN) include TFI + (CC+1) + len = (abtRxBuf[offset] << 8) + abtRxBuf[offset + 1] - 2; + if (((abtRxBuf[offset] + abtRxBuf[offset + 1] + abtRxBuf[offset + 2]) % 256) != 0) { + // TODO: Retry + ERR ("%s", "Length checksum mismatch"); + pnd->iLastError = DEIO; + return -1; + } offset += 3; } else { // Normal frame