Hi, Thanks for your report. I will check my device with your patch. If no problem, I will apply your patch and upload.
Best regards, Nobuhiro 2014-08-27 2:00 GMT+09:00 Steinar H. Gunderson <se...@debian.org>: > Package: libnfc5 > Version: 1.7.1-1 > Severity: normal > Tags: upstream patch > > Hi, > > I tried reporting this upstream > (http://www.libnfc.org/community/topic/1279/timeout-message-from-acr122u-is-deemed-too-short/), > but I never got any response, so I'm thinking it should maybe go through > Debian, since maintainers typically have better relationships with upstream > (or could carry external patches). I'm repeating the bug report and patch > here: > > Hi, > > I have an application where I call nfc_initiator_select_passive_target() in a > loop, and then see if I got a success or not. However, there's seemingly no > way > of discerning timeouts (ie., nobody's holding a tag to the reader) from other > errors (like “someone unplugged the reader”); they all give me NFC_EIO (-1) > back. > > Turning on debug logging yields (on that call): > debug libnfc.driver.acr122_usb TX: 6f 0b 00 00 00 00 00 00 00 00 ff 00 > 00 00 06 d4 60 ff 01 20 10 > [pause while it's looking for tags] > debug libnfc.driver.acr122_usb RX: 80 00 00 00 00 00 00 00 fe 00 > error libnfc.driver.acr122_usb Invalid RDR_to_PC_DataBlock frame > debug libnfc.driver.acr122_usb ACR122 Abort > > Looking at the reader frame, this seems to be a legitimate 0-byte frame with > an > error code of 0xFE, which is ICC_MUTE or “CCID timed out while talking to the > ICC”. (I know nothing about CCID, but this sounds reasonable to me.) > > acr122_usb.c simply has a check saying that the data frame must be at least 12 > bytes, but I can find nothing in the linked CCID spec that requires this; it > seems the limit ought to be 10, not 12. Furthermore, the error value is > ignored. Shouldn't the right thing to do here be to parse this > shorter-than-usual frame and then return NFC_ETIMEOUT? > > FWIW, this patch seems to work for me: > > diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c > index 8a16920..3f8a31e 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,16 @@ 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 +668,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 +707,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; // bError is partially checked above > offset += 1; // bRFU should be 0x00 > > // TFI + PD0 (CC+1) > > -- System Information: > Debian Release: jessie/sid > APT prefers unstable > APT policy: (500, 'unstable'), (1, 'experimental') > Architecture: amd64 (x86_64) > Foreign Architectures: i386 > > Kernel: Linux 3.16.1 (SMP w/4 CPU cores) > Locale: LANG=nb_NO.utf8, LC_CTYPE=nb_NO.utf8 (charmap=UTF-8) > Shell: /bin/sh linked to /bin/dash > > Versions of packages libnfc5 depends on: > ii libc6 2.19-9 > ii libusb-0.1-4 2:0.1.12-24 > ii multiarch-support 2.19-7 > > libnfc5 recommends no packages. > > libnfc5 suggests no packages. > > -- no debconf information -- Nobuhiro Iwamatsu iwamatsu at {nigauri.org / debian.org} GPG ID: 40AD1FA6 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org