fix 'lf t55xx resetread' - NG and better fault handling

This commit is contained in:
iceman1001 2019-09-30 19:47:36 +02:00
parent aeab10d67f
commit fd88d7448e
2 changed files with 19 additions and 9 deletions

View file

@ -1694,9 +1694,8 @@ void T55xxResetRead(uint8_t flags) {
DoPartialAcquisition(0, true, BigBuf_max_traceLen(), 0);
// Turn the field off
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); // field off
reply_mix(CMD_ACK, 0, 0, 0, 0, 0);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
reply_ng(CMD_LF_T55XX_RESET_READ, PM3_SUCCESS, NULL, 0);
LED_A_OFF();
}

View file

@ -2426,19 +2426,30 @@ static int CmdResetRead(const char *Cmd) {
flags = downlink_mode << 3;
PacketResponseNG resp;
clearCommandBuffer();
SendCommandNG(CMD_LF_T55XX_RESET_READ, &flags, sizeof(flags));
if (!WaitForResponseTimeout(CMD_ACK, NULL, 2500)) {
if (!WaitForResponseTimeout(CMD_LF_T55XX_RESET_READ, &resp, 2500)) {
PrintAndLogEx(WARNING, "command execution time out");
return PM3_ETIMEOUT;
}
uint8_t got[BIGBUF_SIZE - 1];
if (!GetFromDevice(BIG_BUF, got, sizeof(got), 0, NULL, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out");
return PM3_ETIMEOUT;
if (resp.status == PM3_SUCCESS) {
uint8_t *got = calloc(BIGBUF_SIZE - 1, sizeof(uint8_t));
if (got == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory");
return PM3_EMALLOC;
}
if (!GetFromDevice(BIG_BUF, got, sizeof(got), 0, NULL, 0, NULL, 2500, false)) {
PrintAndLogEx(WARNING, "command execution time out");
return PM3_ETIMEOUT;
}
setGraphBuf(got, sizeof(got));
free(got);
}
setGraphBuf(got, sizeof(got));
return PM3_SUCCESS;
}