Fixes error libnfc.driver.acr122_usb Invalid RDR_to_PC_DataBlock frame

This commit is contained in:
jarjar 2023-05-27 18:12:06 +00:00
parent 42de50f2b7
commit 80ef76fdda

View File

@ -612,6 +612,7 @@ read:
uint8_t attempted_response = RDR_to_PC_DataBlock; uint8_t attempted_response = RDR_to_PC_DataBlock;
size_t len; size_t len;
int error, status;
if (res == NFC_ETIMEOUT) { if (res == NFC_ETIMEOUT) {
if (DRIVER_DATA(pnd)->abort_flag) { if (DRIVER_DATA(pnd)->abort_flag) {
@ -623,7 +624,7 @@ read:
goto 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"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Invalid RDR_to_PC_DataBlock frame");
// try to interrupt current device state // try to interrupt current device state
acr122_usb_ack(pnd); acr122_usb_ack(pnd);
@ -638,6 +639,16 @@ read:
offset++; offset++;
len = abtRxBuf[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 > 1) && (abtRxBuf[10] == 0xd5))) { // In case we didn't get an immediate answer:
if (len != 2) { if (len != 2) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Wrong reply"); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "%s", "Wrong reply");
@ -666,7 +677,7 @@ read:
goto read; // FIXME May cause some trouble on Touchatag, right ? goto read; // FIXME May cause some trouble on Touchatag, right ?
} }
} }
if (res < 12) { if (res < 10) {
// try to interrupt current device state // try to interrupt current device state
acr122_usb_ack(pnd); acr122_usb_ack(pnd);
pnd->last_error = NFC_EIO; pnd->last_error = NFC_EIO;