Skip to content

Commit 0464886

Browse files
committed
fix: Hitag S Read page failed
1 parent 3f5266b commit 0464886

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

armsrc/hitagS.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,12 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {
12951295

12961296
while ((BUTTON_PRESS() == false) && (data_available() == false)) {
12971297

1298+
if (payload->page_count == 0) {
1299+
if (page_addr > tag.max_page) break;
1300+
} else if (page_addr > 255 || page_addr >= payload->page + payload->page_count) {
1301+
break;
1302+
}
1303+
12981304
WDT_HIT();
12991305

13001306
size_t rxlen = 0;
@@ -1312,7 +1318,7 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {
13121318

13131319
if (rxlen != 40) {
13141320
DBG Dbprintf("Read page failed!");
1315-
card.pages_reason[page_index] = -4;
1321+
card.pages_reason[page_index] = -11;
13161322
// status = PM3_ERFTRANS;
13171323
// goto read_end;
13181324
page_addr++;
@@ -1362,18 +1368,12 @@ void hts_read(const lf_hitag_data_t *payload, bool ledcontrol) {
13621368
//if the authentication is done with a challenge the key and password are unknown
13631369
DBG Dbprintf("Page[ 2]: __ __ __ __");
13641370
DBG Dbprintf("Page[ 3]: __ __ __ __");
1365-
card.pages_reason[page_index++] = -4;
1366-
card.pages_reason[page_index++] = -4;
1371+
card.pages_reason[page_index++] = -11;
1372+
card.pages_reason[page_index++] = -11;
13671373
}
13681374
// since page 2+3 are not accessible when LKP == 1 and AUT == 1 fastforward to next readable page
13691375
page_addr = 4;
13701376
}
1371-
1372-
if (payload->page_count == 0) {
1373-
if (page_addr > tag.max_page) break;
1374-
} else if (page_addr > 255 || page_addr >= payload->page + payload->page_count) {
1375-
break;
1376-
}
13771377
}
13781378

13791379
read_end:

client/src/cmdlfhitaghts.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ static void print_error(int8_t reason) {
226226
case -10:
227227
PrintAndLogEx(FAILED, "Write to page failed!");
228228
break;
229+
case -11:
230+
PrintAndLogEx(FAILED, "Read page failed!");
231+
break;
229232
default:
230233
// PM3_REASON_UNKNOWN
231234
PrintAndLogEx(DEBUG, "DEBUG: Error - Hitag S failed");
@@ -404,8 +407,10 @@ static int CmdLFHitagSRead(const char *Cmd) {
404407
PrintAndLogEx(NORMAL, "Key");
405408
} else
406409
PrintAndLogEx(NORMAL, "Data");
407-
} else
408-
PrintAndLogEx(INFO, "%02u | -- -- -- -- | read failed reason: " _YELLOW_("%d"), page_addr, card->pages_reason[i]);
410+
} else {
411+
PrintAndLogEx(INFO, "% 3u | -- -- -- -- | .... | N/A | " NOLF, page_addr);
412+
print_error(card->pages_reason[i]);
413+
}
409414
}
410415

411416
PrintAndLogEx(INFO, "----+-------------+-------+------+------");

0 commit comments

Comments
 (0)