+ if (select){ //auto select 14b tag
+ uint8_t cmd2[16];
+ bool crc2 = true;
+ uint8_t cmdLen;
+
+ if (SRx) {
+ // REQ SRx
+ cmdLen = 2;
+ cmd2[0] = 0x06;
+ cmd2[1] = 0x00;
+ } else {
+ cmdLen = 3;
+ // REQB
+ cmd2[0] = 0x05;
+ cmd2[1] = 0x00;
+ cmd2[2] = 0x08;
+ }
+
+ if (HF14BCmdRaw(true, &crc2, true, cmd2, &cmdLen, false)==0) return rawClose();
+
+ if ( SRx && (cmdLen != 3 || !crc2) ) return rawClose();
+ else if (cmd2[0] != 0x50 || cmdLen != 14 || !crc2) return rawClose();
+
+ uint8_t chipID = 0;
+ if (SRx) {
+ // select
+ chipID = cmd2[0];
+ cmd2[0] = 0x0E;
+ cmd2[1] = chipID;
+ cmdLen = 2;
+ } else {
+ // attrib
+ cmd2[0] = 0x1D;
+ // UID from cmd2[1 - 4]
+ cmd2[5] = 0x00;
+ cmd2[6] = 0x08;
+ cmd2[7] = 0x01;
+ cmd2[8] = 0x00;
+ cmdLen = 9;
+ }
+
+ if (HF14BCmdRaw(true, &crc2, true, cmd2, &cmdLen, false)==0) return rawClose();
+
+ if (cmdLen != 3 || !crc2) return rawClose();
+ if (SRx && cmd2[0] != chipID) return rawClose();
+ }