|
0 |
Description: Timeout message from ACR122U is deemed too short
|
|
1 |
Forwarded: http://www.libnfc.org/community/topic/1279/timeout-message-from-acr122u-is-deemed-too-short/
|
|
2 |
Author: Steinar H. Gunderson <sesse@debian.org>
|
|
3 |
Bug-Debian: http://bugs.debian.org/759355
|
|
4 |
Last-Update: 2014-09-06
|
|
5 |
|
|
6 |
diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c
|
|
7 |
index 8a16920..3f8a31e 100644
|
|
8 |
--- a/libnfc/drivers/acr122_usb.c
|
|
9 |
+++ b/libnfc/drivers/acr122_usb.c
|
|
10 |
@@ -603,6 +603,7 @@ read:
|
|
11 |
|
|
12 |
uint8_t attempted_response = RDR_to_PC_DataBlock;
|
|
13 |
size_t len;
|
|
14 |
+ int error, status;
|
|
15 |
|
|
16 |
if (res == NFC_ETIMEOUT) {
|
|
17 |
if (DRIVER_DATA(pnd)->abort_flag) {
|
|
18 |
@@ -614,7 +615,7 @@ read:
|
|
19 |
goto read;
|
|
20 |
}
|
|
21 |
}
|
|
22 |
- if (res < 12) {
|
|
23 |
+ if (res < 10) {
|
|
24 |
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Invalid RDR_to_PC_DataBlock frame");
|
|
25 |
// try to interrupt current device state
|
|
26 |
acr122_usb_ack(pnd);
|
|
27 |
@@ -629,6 +630,16 @@ read:
|
|
28 |
offset++;
|
|
29 |
|
|
30 |
len = abtRxBuf[offset++];
|
|
31 |
+ status = abtRxBuf[7];
|
|
32 |
+ error = abtRxBuf[8];
|
|
33 |
+ if (len == 0 && error == 0xFE) { // ICC_MUTE; XXX check for more errors
|
|
34 |
+ // Do not check status; my ACR122U seemingly has status=0 in this case,
|
|
35 |
+ // even though the spec says it should have had bmCommandStatus=1
|
|
36 |
+ // and bmICCStatus=1.
|
|
37 |
+ log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "Command timed out");
|
|
38 |
+ pnd->last_error = NFC_ETIMEOUT;
|
|
39 |
+ return pnd->last_error;
|
|
40 |
+ }
|
|
41 |
if (!((len > 1) && (abtRxBuf[10] == 0xd5))) { // In case we didn't get an immediate answer:
|
|
42 |
if (len != 2) {
|
|
43 |
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Wrong reply");
|
|
44 |
@@ -657,7 +668,7 @@ read:
|
|
45 |
goto read; // FIXME May cause some trouble on Touchatag, right ?
|
|
46 |
}
|
|
47 |
}
|
|
48 |
- if (res < 12) {
|
|
49 |
+ if (res < 10) {
|
|
50 |
// try to interrupt current device state
|
|
51 |
acr122_usb_ack(pnd);
|
|
52 |
pnd->last_error = NFC_EIO;
|
|
53 |
@@ -696,7 +707,7 @@ read:
|
|
54 |
|
|
55 |
// Skip CCID remaining bytes
|
|
56 |
offset += 2; // bSlot and bSeq are not used
|
|
57 |
- offset += 2; // XXX bStatus and bError should maybe checked ?
|
|
58 |
+ offset += 2; // bError is partially checked above
|
|
59 |
offset += 1; // bRFU should be 0x00
|
|
60 |
|
|
61 |
// TFI + PD0 (CC+1)
|