- // Can be set from emulator memory, incoming data
- // and can be 7 or 4 bytes long
- if (flags & FLAG_4B_UID_IN_DATA)
- {
- // 4B uid comes from data-portion of packet
- memcpy(rUIDBCC1,datain,4);
- rUIDBCC1[4] = rUIDBCC1[0] ^ rUIDBCC1[1] ^ rUIDBCC1[2] ^ rUIDBCC1[3];
-
- } else if (flags & FLAG_7B_UID_IN_DATA) {
- // 7B uid comes from data-portion of packet
- memcpy(&rUIDBCC1[1],datain,3);
- memcpy(rUIDBCC2, datain+3, 4);
- _7BUID = true;
- } else {
- // get UID from emul memory
- emlGetMemBt(receivedCmd, 7, 1);
- _7BUID = !(receivedCmd[0] == 0x00);
- if (!_7BUID) { // ---------- 4BUID
- emlGetMemBt(rUIDBCC1, 0, 4);
- } else { // ---------- 7BUID
- emlGetMemBt(&rUIDBCC1[1], 0, 3);
- emlGetMemBt(rUIDBCC2, 3, 4);
- }
- }
-
- // save uid.
- ar_nr_responses[0*5] = bytes_to_num(rUIDBCC1+1, 3);
- if ( _7BUID )
- ar_nr_responses[0*5+1] = bytes_to_num(rUIDBCC2, 4);
-
- /*
- * Regardless of what method was used to set the UID, set fifth byte and modify
- * the ATQA for 4 or 7-byte UID
- */
- rUIDBCC1[4] = rUIDBCC1[0] ^ rUIDBCC1[1] ^ rUIDBCC1[2] ^ rUIDBCC1[3];
- if (_7BUID) {
- rATQA[0] = 0x44;
- rUIDBCC1[0] = 0x88;
- rUIDBCC1[4] = rUIDBCC1[0] ^ rUIDBCC1[1] ^ rUIDBCC1[2] ^ rUIDBCC1[3];
- rUIDBCC2[4] = rUIDBCC2[0] ^ rUIDBCC2[1] ^ rUIDBCC2[2] ^ rUIDBCC2[3];
+ // Can be set from emulator memory or incoming data
+ // Length: 4,7,or 10 bytes
+ if ( (flags & FLAG_UID_IN_EMUL) == FLAG_UID_IN_EMUL)
+ emlGetMemBt(datain, 0, 10); // load 10bytes from EMUL to the datain pointer. to be used below.
+
+ if ( (flags & FLAG_4B_UID_IN_DATA) == FLAG_4B_UID_IN_DATA) {
+ memcpy(rUIDBCC1, datain, 4);
+ _UID_LEN = 4;
+ } else if ( (flags & FLAG_7B_UID_IN_DATA) == FLAG_7B_UID_IN_DATA) {
+ memcpy(&rUIDBCC1[1], datain, 3);
+ memcpy( rUIDBCC2, datain+3, 4);
+ _UID_LEN = 7;
+ } else if ( (flags & FLAG_10B_UID_IN_DATA) == FLAG_10B_UID_IN_DATA) {
+ memcpy(&rUIDBCC1[1], datain, 3);
+ memcpy(&rUIDBCC2[1], datain+3, 3);
+ memcpy( rUIDBCC3, datain+6, 4);
+ _UID_LEN = 10;