Commit af7eef0c authored by Romuald Conty's avatar Romuald Conty

acr122_usb: check received Status Word (Touchatag)

Test if SW1 is 0x61 (means more bytes have to be read) before using SW2 as length.

Update issue 251
The driver now check that Status Word (SW1) is equals to 0x61 (more data available) before using SW2 as length.
If SW is not as expected, it show SW1 and SW2.
parent 5757fafe
......@@ -185,6 +185,9 @@ struct acr122_usb_data {
#define RDR_to_PC_DataBlock 0x80
#define RDR_to_PC_Escape 0x83
// ISO 7816-4
#define SW1_More_Data_Available 0x61
// This frame template is copied at init time
// Its designed for TAMA sending but is also used for simple ADPU frame: acr122_build_frame_from_apdu() will overwrite needed bytes
const uint8_t acr122_usb_frame_template[] = {
......@@ -649,6 +652,11 @@ read:
pnd->last_error = NFC_EIO;
return pnd->last_error;
}
if (abtRxBuf[10] != SW1_More_Data_Available) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unexpected Status Word (SW1: %02x SW2: %02x)", abtRxBuf[10], abtRxBuf[11]);
pnd->last_error = NFC_EIO;
return pnd->last_error;
}
acr122_usb_send_apdu(pnd, APDU_GetAdditionnalData, 0x00, 0x00, NULL, 0, abtRxBuf[11], abtRxBuf, sizeof(abtRxBuf));
offset = 0;
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment