- if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) {
- uint8_t isOK = resp.arg[0] & 0xFF;
- uint16_t tagtype = resp.arg[1] & 0xFFF;
- if ( isOK ) {
- PrintAndLog(" UID : %s", sprint_hex(resp.d.asBytes, 4));
- switch(tagtype) {
- case 22: PrintAndLog("MIM22 card (22bytes)"); break;
- case 256: PrintAndLog("MIM256 card (256bytes)"); break;
- case 1024: PrintAndLog("MIM1024 card (1024bytes)"); break;
- default: {
- PrintAndLog("Unknown card format: %x", tagtype);
- return 1;
- }
- }
- } else {
- PrintAndLog("legic card select failed");
+ if (!WaitForResponseTimeout(CMD_ACK, &resp, 500)) {
+ if ( verbose ) PrintAndLog("command execution time out");
+ return 1;
+ }
+
+ uint8_t isOK = resp.arg[0] & 0xFF;
+ if ( !isOK ) {
+ if ( verbose ) PrintAndLog("legic card select failed");
+ return 1;
+ }
+
+ legic_card_select_t card;
+ memcpy(&card, (legic_card_select_t *)resp.d.asBytes, sizeof(legic_card_select_t));
+
+ PrintAndLog(" UID : %s", sprint_hex(card.uid, sizeof(card.uid)));
+ switch(card.cardsize) {
+ case 22:
+ case 256:
+ case 1024:
+ PrintAndLog(" TYPE : MIM%d card (%d bytes)", card.cardsize, card.cardsize); break;
+ default: {
+ PrintAndLog("Unknown card format: %d", card.cardsize);