@@ -612,6 +612,7 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
612612
613613 uint8_t attempted_response = RDR_to_PC_DataBlock ;
614614 size_t len ;
615+ int error , status ;
615616
616617 if (res == NFC_ETIMEOUT ) {
617618 if (DRIVER_DATA (pnd )-> abort_flag ) {
@@ -623,7 +624,7 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
623624 goto read ;
624625 }
625626 }
626- if (res < 12 ) {
627+ if (res < 10 ) {
627628 log_put (LOG_GROUP , LOG_CATEGORY , NFC_LOG_PRIORITY_ERROR , "%s" , "Invalid RDR_to_PC_DataBlock frame" );
628629 // try to interrupt current device state
629630 acr122_usb_ack (pnd );
@@ -638,6 +639,17 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
638639 offset ++ ;
639640
640641 len = abtRxBuf [offset ++ ];
642+ status = abtRxBuf [7 ];
643+ error = abtRxBuf [8 ];
644+ if (len == 0 && error == 0xFE ) { // ICC_MUTE; XXX check for more errors
645+ // Do not check status; my ACR122U seemingly has status=0 in this case,
646+ // even though the spec says it should have had bmCommandStatus=1
647+ // and bmICCStatus=1.
648+ log_put (LOG_GROUP , LOG_CATEGORY , NFC_LOG_PRIORITY_DEBUG , "%s" , "Command timed out" );
649+ pnd -> last_error = NFC_ETIMEOUT ;
650+ return pnd -> last_error ;
651+ }
652+
641653 if (!((len > 1 ) && (abtRxBuf [10 ] == 0xd5 ))) { // In case we didn't get an immediate answer:
642654 if (len != 2 ) {
643655 log_put (LOG_GROUP , LOG_CATEGORY , NFC_LOG_PRIORITY_ERROR , "%s" , "Wrong reply" );
@@ -666,7 +678,7 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
666678 goto read ; // FIXME May cause some trouble on Touchatag, right ?
667679 }
668680 }
669- if (res < 12 ) {
681+ if (res < 10 ) {
670682 // try to interrupt current device state
671683 acr122_usb_ack (pnd );
672684 pnd -> last_error = NFC_EIO ;
@@ -705,7 +717,7 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
705717
706718 // Skip CCID remaining bytes
707719 offset += 2 ; // bSlot and bSeq are not used
708- offset += 2 ; // XXX bStatus and bError should maybe checked ?
720+ offset += 2 ; // bStatus and bError is partially checked
709721 offset += 1 ; // bRFU should be 0x00
710722
711723 // TFI + PD0 (CC+1)
0 commit comments