+
+
+ // try to request ATS even if tag claims not to support it
+ if (select_status == 2) {
+ uint8_t rats[] = { 0xE0, 0x80 }; // FSDI=8 (FSD=256), CID=0
+ c.arg[0] = ISO14A_RAW | ISO14A_APPEND_CRC | ISO14A_NO_DISCONNECT;
+ c.arg[1] = 2;
+ c.arg[2] = 0;
+ memcpy(c.d.asBytes, rats, 2);
+ SendCommand(&c);
+ WaitForResponse(CMD_ACK,&resp);
+
+ memcpy(&card.ats, resp.d.asBytes, resp.arg[0]);
+ card.ats_len = resp.arg[0]; // note: ats_len includes CRC Bytes
+ }
+
+ if(card.ats_len >= 3) { // a valid ATS consists of at least the length byte (TL) and 2 CRC bytes