From dcf63ca057a91633ea39dcba548e192db16fb62f Mon Sep 17 00:00:00 2001 From: pwpiwi Date: Wed, 4 Dec 2019 19:29:10 +0100 Subject: [PATCH] fix 'hf 15 csetuid' * don't break when tag doesn't respond to magic commands --- armsrc/iso15693.c | 8 ++++---- client/cmdhf15.c | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/armsrc/iso15693.c b/armsrc/iso15693.c index 453e7a96..665786bf 100644 --- a/armsrc/iso15693.c +++ b/armsrc/iso15693.c @@ -1854,10 +1854,10 @@ void SetTag15693Uid(uint8_t *uid) { DbdecodeIso15693Answer(recvlen, recvbuf); } } - - if (recvlen <= 0) { - break; - } + // Note: need to know if we expect an answer from one of the magic commands + // if (recvlen < 0) { + // break; + // } } cmd_send(CMD_ACK, recvlen, 0, 0, NULL, 0); diff --git a/client/cmdhf15.c b/client/cmdhf15.c index 1e165101..cc86841b 100644 --- a/client/cmdhf15.c +++ b/client/cmdhf15.c @@ -984,17 +984,24 @@ static int CmdHF15CSetUID(const char *Cmd) { SendCommand(&c); UsbCommand resp; - if (WaitForResponseTimeout(CMD_ACK, &resp, 1000)) { + if (WaitForResponseTimeout(CMD_ACK, &resp, 2000)) { int recv_len = resp.arg[0]; + uint8_t *recv = resp.d.asBytes; if (recv_len == 0) { - PrintAndLog("received SOF only. Maybe Picopass/iCLASS?"); + PrintAndLog("Received SOF only. Maybe Picopass/iCLASS?"); } else if (recv_len == -1) { - PrintAndLog("card didn't respond"); + PrintAndLog("Tag didn't respond"); } else if (recv_len == -2) { - PrintAndLog("receive buffer overflow"); + PrintAndLog("Receive buffer overflow"); + } else if (ISO15693_CRC_CHECK != Crc(recv, recv_len)) { + PrintAndLog("CRC check failed on Tag response"); + } else if (!(recv[0] & ISO15693_RES_ERROR)) { + PrintAndLog("Tag returned OK"); + } else { + PrintAndLog("Tag returned Error %i: %s", recv[1], TagErrorStr(recv[1])); } } else { - PrintAndLog("timeout while waiting for reply."); + PrintAndLog("No answer from Proxmark"); } if (!getUID(newUid)) {