Created
January 2, 2016 23:06
-
-
Save danieloneill/3be43d5374c80d89ea73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c | |
index 8a16920..b3df024 100644 | |
--- a/libnfc/drivers/acr122_usb.c | |
+++ b/libnfc/drivers/acr122_usb.c | |
@@ -603,6 +603,7 @@ read: | |
uint8_t attempted_response = RDR_to_PC_DataBlock; | |
size_t len; | |
+ int error, status; | |
if (res == NFC_ETIMEOUT) { | |
if (DRIVER_DATA(pnd)->abort_flag) { | |
@@ -614,7 +615,7 @@ read: | |
goto read; | |
} | |
} | |
- if (res < 12) { | |
+ if (res < 10) { | |
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Invalid RDR_to_PC_DataBlock frame"); | |
// try to interrupt current device state | |
acr122_usb_ack(pnd); | |
@@ -629,6 +630,17 @@ read: | |
offset++; | |
len = abtRxBuf[offset++]; | |
+ status = abtRxBuf[7]; | |
+ error = abtRxBuf[8]; | |
+ if (len == 0 && error == 0xFE) { // ICC_MUTE; XXX check for more errors | |
+ // Do not check status; my ACR122U seemingly has status=0 in this case, | |
+ // even though the spec says it should have had bmCommandStatus=1 | |
+ // and bmICCStatus=1. | |
+ log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "Command timed out"); | |
+ pnd->last_error = NFC_ETIMEOUT; | |
+ return pnd->last_error; | |
+ } | |
+ | |
if (!((len > 1) && (abtRxBuf[10] == 0xd5))) { // In case we didn't get an immediate answer: | |
if (len != 2) { | |
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Wrong reply"); | |
@@ -657,7 +669,7 @@ read: | |
goto read; // FIXME May cause some trouble on Touchatag, right ? | |
} | |
} | |
- if (res < 12) { | |
+ if (res < 10) { | |
// try to interrupt current device state | |
acr122_usb_ack(pnd); | |
pnd->last_error = NFC_EIO; | |
@@ -696,7 +708,7 @@ read: | |
// Skip CCID remaining bytes | |
offset += 2; // bSlot and bSeq are not used | |
- offset += 2; // XXX bStatus and bError should maybe checked ? | |
+ offset += 2; // bStatus and bError is partially checked | |
offset += 1; // bRFU should be 0x00 | |
// TFI + PD0 (CC+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment