fixed the spinner and download reporting
This commit is contained in:
1 parent
af0b0095ca
commit
054fae4ac1
9 files changed
+65
-39
No files matched your search
+12
-12
@@ -93,7 +93,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
uint8_t success[COUNT_OF_PROTOCOLS] = {0};
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for ThinFilm tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for ThinFilm tag...");
|
||||
if (IfPm3NfcBarcode()) {
|
||||
if (infoThinFilm(false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Thinfilm tag") " found\n");
|
||||
@@ -103,7 +103,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for Topaz tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for Topaz tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
if (readTopazUid(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Topaz tag") " found\n");
|
||||
@@ -113,7 +113,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for LTO-CM tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for LTO-CM tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
if (reader_lto(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LTO-CM tag") " found\n");
|
||||
@@ -123,7 +123,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for ISO14443-A tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO14443-A tag...");
|
||||
if (IfPm3Iso14443a()) {
|
||||
int sel_state = infoHF14A(false, false, false);
|
||||
if (sel_state > 0) {
|
||||
@@ -152,7 +152,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
*/
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for LEGIC tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for LEGIC tag...");
|
||||
if (IfPm3Legicrf()) {
|
||||
if (readLegicUid(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("LEGIC Prime tag") " found\n");
|
||||
@@ -163,7 +163,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
// texkom
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for TEXKOM tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for TEXKOM tag...");
|
||||
if (read_texkom_uid(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("TEXKOM tag") " found\n");
|
||||
success[PROTO_TEXKOM] = true;
|
||||
@@ -172,7 +172,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
// xerox
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for Fuji/Xerox tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for Fuji/Xerox tag...");
|
||||
if (IfPm3Iso14443b()) {
|
||||
if (read_xerox_uid(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("Fuji/Xerox tag") " found\n");
|
||||
@@ -183,7 +183,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
// 14b is the longest test
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for ISO14443-B tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO14443-B tag...");
|
||||
if (IfPm3Iso14443b()) {
|
||||
if (readHF14B(false, false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 14443-B tag") " found\n");
|
||||
@@ -195,7 +195,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
// OBS! This triggers a swap to FPGA_BITSTREAM_HF_15 == 1.5sec delay
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for ISO15693 tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for ISO15693 tag...");
|
||||
if (IfPm3Iso15693()) {
|
||||
if (readHF15Uid(false, true)) {
|
||||
PrintAndLogEx(SUCCESS, "Valid " _GREEN_("ISO 15693 tag") " found\n");
|
||||
@@ -205,7 +205,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
}
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for iCLASS / PicoPass tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for iCLASS / PicoPass tag...");
|
||||
if (IfPm3Iclass()) {
|
||||
if (read_iclass_csn(false, false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("iCLASS tag / PicoPass tag") " found\n");
|
||||
@@ -217,7 +217,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
// OBS! This triggers a swap to FPGA_BITSTREAM_HF_FELICA == 1.5sec delay
|
||||
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for FeliCa tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for FeliCa tag...");
|
||||
if (IfPm3Felica()) {
|
||||
if (read_felica_uid(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("ISO 18092 / FeliCa tag") " found\n");
|
||||
@@ -232,7 +232,7 @@ int CmdHFSearch(const char *Cmd) {
|
||||
|
||||
/*
|
||||
PROMPT_CLEARLINE;
|
||||
PrintAndLogEx(INPLACE, " Searching for CryptoRF tag...");
|
||||
PrintAndLogEx(INPLACE, "Searching for CryptoRF tag...");
|
||||
if (IfPm3Iso14443b()) {
|
||||
if (readHFCryptoRF(false, false) == PM3_SUCCESS) {
|
||||
PrintAndLogEx(SUCCESS, "\nValid " _GREEN_("CryptoRF tag") " found\n");
|
||||
|
||||
@@ -4315,9 +4315,9 @@ static int CmdHFiClass_TearBlock(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (tearoff_loop > 1) {
|
||||
PrintAndLogEx(INPLACE, " Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us - "_YELLOW_("%3u")" iter", params.delay_us, (tearoff_end & 0xFFFF), loop_count + 1);
|
||||
PrintAndLogEx(INPLACE, "Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us - "_YELLOW_("%3u")" iter", params.delay_us, (tearoff_end & 0xFFFF), loop_count + 1);
|
||||
} else {
|
||||
PrintAndLogEx(INPLACE, " Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us", params.delay_us, (tearoff_end & 0xFFFF));
|
||||
PrintAndLogEx(INPLACE, "Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us", params.delay_us, (tearoff_end & 0xFFFF));
|
||||
}
|
||||
|
||||
// write block - don't check the return value. As a tear-off occurred, the write failed.
|
||||
@@ -4814,9 +4814,9 @@ static int CmdHFiClass_BlackTears(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (tearoff_loop > 1) {
|
||||
PrintAndLogEx(INPLACE, " Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us - "_YELLOW_("%3u")" iter", params.delay_us, (tearoff_end & 0xFFFF), loop_count + 1);
|
||||
PrintAndLogEx(INPLACE, "Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us - "_YELLOW_("%3u")" iter", params.delay_us, (tearoff_end & 0xFFFF), loop_count + 1);
|
||||
} else {
|
||||
PrintAndLogEx(INPLACE, " Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us", params.delay_us, (tearoff_end & 0xFFFF));
|
||||
PrintAndLogEx(INPLACE, "Tear off delay "_YELLOW_("%u")" / "_YELLOW_("%d")" us", params.delay_us, (tearoff_end & 0xFFFF));
|
||||
}
|
||||
|
||||
// write block - don't check the return value. As a tear-off occurred, the write failed.
|
||||
|
||||
@@ -6873,7 +6873,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
post_tear_check = (post_tear == 0xBD);
|
||||
a = (pre[0] | pre[1] << 8 | pre[2] << 16);
|
||||
b = (post[0] | post[1] << 8 | post[2] << 16);
|
||||
PrintAndLogEx(INPLACE, " Delay: " _YELLOW_("%d") " Tear: %s Counter: " _YELLOW_("%s") ""
|
||||
PrintAndLogEx(INPLACE, "Delay: " _YELLOW_("%d") " Tear: %s Counter: " _YELLOW_("%s") ""
|
||||
, delay_bd
|
||||
, sprint_hex_inrow(tear, sizeof(tear))
|
||||
, poststr
|
||||
@@ -6984,7 +6984,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) {
|
||||
|
||||
post_tear_check = (post_tear == 0xBD);
|
||||
|
||||
PrintAndLogEx(INPLACE, " Delay: " _YELLOW_("%d") " Tear: %s Counter: " _YELLOW_("%s") ""
|
||||
PrintAndLogEx(INPLACE, "Delay: " _YELLOW_("%d") " Tear: %s Counter: " _YELLOW_("%s") ""
|
||||
, delay_00
|
||||
, sprint_hex_inrow(tear, sizeof(tear))
|
||||
, poststr
|
||||
|
||||
+10
-2
@@ -831,7 +831,11 @@ static int lf_read_internal(bool realtime, bool verbose, uint64_t samples, bool
|
||||
sample_bytes = WaitForRawDataTimeout(realtimeBuf, sample_bytes, 1000, true, false);
|
||||
}
|
||||
samples = sample_bytes * 8 / bits_per_sample;
|
||||
PrintAndLogEx(INFO, "Done: %" PRIu64 " samples (%zu bytes)", samples, sample_bytes);
|
||||
// the inline "Received x / y bytes" counter already says the transfer is
|
||||
// done, so only repeat it in samples when asked
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "Done: %" PRIu64 " samples (%zu bytes)", samples, sample_bytes);
|
||||
}
|
||||
if (samples != 0) {
|
||||
getSamplesFromBufEx(realtimeBuf, samples, bits_per_sample, verbose);
|
||||
}
|
||||
@@ -966,7 +970,11 @@ int lf_sniff(bool realtime, bool verbose, uint64_t samples) {
|
||||
sample_bytes = WaitForRawDataTimeout(realtimeBuf, sample_bytes, 1000, true, false);
|
||||
}
|
||||
samples = sample_bytes * 8 / bits_per_sample;
|
||||
PrintAndLogEx(INFO, "Done: %" PRIu64 " samples (%zu bytes)", samples, sample_bytes);
|
||||
// the inline "Received x / y bytes" counter already says the transfer is
|
||||
// done, so only repeat it in samples when asked
|
||||
if (verbose) {
|
||||
PrintAndLogEx(INFO, "Done: %" PRIu64 " samples (%zu bytes)", samples, sample_bytes);
|
||||
}
|
||||
if (samples != 0) {
|
||||
getSamplesFromBufEx(realtimeBuf, samples, bits_per_sample, verbose);
|
||||
}
|
||||
|
||||
@@ -512,6 +512,9 @@ static int CmdCOTAGReader(const char *Cmd) {
|
||||
}
|
||||
|
||||
if (cm || realtime) {
|
||||
// close any inline line the caller left open, ie: `lf search` printing
|
||||
// "Searching for COTAG tag..." right before this
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(INFO, "Press " _GREEN_("<Enter>") " to exit");
|
||||
}
|
||||
|
||||
|
||||
@@ -765,7 +765,7 @@ static int CmdLFHitagSRestore(const char *Cmd) {
|
||||
packet.page = page;
|
||||
memcpy(packet.data, &dump_bytes[offset], HITAGS_PAGE_SIZE);
|
||||
|
||||
PrintAndLogEx(INPLACE, " Writing page "_YELLOW_("%d")", data: " _GREEN_("%02X %02X %02X %02X"), page,
|
||||
PrintAndLogEx(INPLACE, "Writing page "_YELLOW_("%d")", data: " _GREEN_("%02X %02X %02X %02X"), page,
|
||||
dump_bytes[offset],
|
||||
dump_bytes[offset + 1],
|
||||
dump_bytes[offset + 2],
|
||||
|
||||
+30
-17
@@ -78,7 +78,7 @@ static uint64_t timeout_start_time;
|
||||
|
||||
static uint64_t last_packet_time;
|
||||
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd, uint32_t req_cmd);
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, bool show_progress, uint32_t rec_cmd, uint32_t req_cmd);
|
||||
|
||||
// Wait until the comm thread has actually put a queued command on the wire.
|
||||
// Callers used to sleep a fixed guess instead, which was reasonable when a
|
||||
@@ -1047,8 +1047,9 @@ static size_t communication_delay(void) {
|
||||
* @return the number of received bytes
|
||||
*/
|
||||
size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, bool show_process, bool keep_raw_mode) {
|
||||
uint8_t print_counter = 0;
|
||||
size_t last_pos = 0;
|
||||
uint64_t last_update = 0;
|
||||
bool printed_progress = false;
|
||||
|
||||
// Add delay depending on the communication channel & speed
|
||||
if (ms_timeout != (size_t) - 1) {
|
||||
@@ -1084,16 +1085,26 @@ size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, boo
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Print process when (print_counter % 64) == 0
|
||||
if (show_process && (print_counter & 0x3F) == 0) {
|
||||
PrintAndLogEx(INFO, "[%zu/%zu]", pos, len);
|
||||
// one line that updates in place, not a line per update
|
||||
if (show_process && ((msclock() - last_update > 100) || (pos == len))) {
|
||||
PrintAndLogEx(INPLACE, "Received " _YELLOW_("%zu") " / " _YELLOW_("%zu") " bytes (" _YELLOW_("%zu") "%%)"
|
||||
, pos
|
||||
, len
|
||||
, (pos * 100) / len
|
||||
);
|
||||
last_update = msclock();
|
||||
printed_progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
print_counter++;
|
||||
last_pos = pos;
|
||||
msleep(10);
|
||||
}
|
||||
|
||||
if (printed_progress) {
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
}
|
||||
|
||||
if (pos == len && (ms_timeout != (size_t) - 1) && (keep_raw_mode == false)) {
|
||||
// If ms_timeout != -1, when the desired data is received, tell the arm side
|
||||
// to stop the current process, and wait for some time to make sure the process
|
||||
@@ -1228,12 +1239,12 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
|
||||
case BIG_BUF: {
|
||||
download_req_t req = { .start_index = start_index, .bytes = bytes };
|
||||
SendCommandNG(CMD_DOWNLOAD_BIGBUF, (uint8_t *)&req, sizeof(req));
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_BIGBUF, CMD_DOWNLOAD_BIGBUF);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, false, CMD_DOWNLOADED_BIGBUF, CMD_DOWNLOAD_BIGBUF);
|
||||
}
|
||||
case BIG_BUF_EML: {
|
||||
download_req_t req = { .start_index = start_index, .bytes = bytes };
|
||||
SendCommandNG(CMD_DOWNLOAD_EML_BIGBUF, (uint8_t *)&req, sizeof(req));
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_EML_BIGBUF, CMD_DOWNLOAD_EML_BIGBUF);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, false, CMD_DOWNLOADED_EML_BIGBUF, CMD_DOWNLOAD_EML_BIGBUF);
|
||||
}
|
||||
case SPIFFS: {
|
||||
uint8_t sbuf[PM3_CMD_DATA_SIZE] = {0};
|
||||
@@ -1244,40 +1255,42 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3
|
||||
memcpy(sreq->data, data, datalen);
|
||||
}
|
||||
SendCommandNG(CMD_SPIFFS_DOWNLOAD, sbuf, sizeof(download_req_t) + datalen);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_SPIFFS_DOWNLOADED, CMD_SPIFFS_DOWNLOAD);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, true, CMD_SPIFFS_DOWNLOADED, CMD_SPIFFS_DOWNLOAD);
|
||||
}
|
||||
case FLASH_MEM: {
|
||||
download_req_t req = { .start_index = start_index, .bytes = bytes };
|
||||
SendCommandNG(CMD_FLASHMEM_DOWNLOAD, (uint8_t *)&req, sizeof(req));
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_FLASHMEM_DOWNLOADED, CMD_FLASHMEM_DOWNLOAD);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, true, CMD_FLASHMEM_DOWNLOADED, CMD_FLASHMEM_DOWNLOAD);
|
||||
}
|
||||
case SIM_MEM: {
|
||||
//SendCommandNG(CMD_DOWNLOAD_SIM_MEM, (uint8_t *)&req, sizeof(req));
|
||||
//return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_DOWNLOADED_SIMMEM);
|
||||
//return dl_it(dest, bytes, response, ms_timeout, show_warning, false, CMD_DOWNLOADED_SIMMEM);
|
||||
return false;
|
||||
}
|
||||
case FPGA_MEM: {
|
||||
SendCommandNG(CMD_FPGAMEM_DOWNLOAD, NULL, 0);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_FPGAMEM_DOWNLOADED, CMD_FPGAMEM_DOWNLOAD);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, false, CMD_FPGAMEM_DOWNLOADED, CMD_FPGAMEM_DOWNLOAD);
|
||||
}
|
||||
case MCU_FLASH:
|
||||
case MCU_MEM: {
|
||||
uint32_t flags = (memtype == MCU_MEM) ? READ_MEM_DOWNLOAD_FLAG_RAW : 0;
|
||||
SendCommandBL(CMD_READ_MEM_DOWNLOAD, start_index, bytes, flags, NULL, 0);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, CMD_READ_MEM_DOWNLOADED, CMD_READ_MEM_DOWNLOAD);
|
||||
return dl_it(dest, bytes, response, ms_timeout, show_warning, true, CMD_READ_MEM_DOWNLOADED, CMD_READ_MEM_DOWNLOAD);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, uint32_t rec_cmd, uint32_t req_cmd) {
|
||||
static bool dl_it(uint8_t *dest, uint32_t bytes, PacketResponseNG *response, size_t ms_timeout, bool show_warning, bool show_progress, uint32_t rec_cmd, uint32_t req_cmd) {
|
||||
|
||||
uint32_t bytes_completed = 0;
|
||||
__atomic_store_n(&timeout_start_time, msclock(), __ATOMIC_SEQ_CST);
|
||||
|
||||
// inline feedback. Small transfers finish before a line could be read, so
|
||||
// only the ones that actually take time say anything
|
||||
const bool show_progress = (bytes > 4096);
|
||||
// Inline feedback, only for the flash backed transfers the caller asked it
|
||||
// for. BigBuf reads are a memcpy over USB and every command does them, so
|
||||
// a progress line there is just noise. Small transfers finish before a
|
||||
// line could be read.
|
||||
show_progress = (show_progress && (bytes > 4096));
|
||||
uint64_t last_update = 0;
|
||||
|
||||
// Add delay depending on the communication channel & speed
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ void PrintAndLogEx(logLevel_t level, const char *fmt, ...) {
|
||||
char *token = NULL;
|
||||
char *tmp_ptr = NULL;
|
||||
FILE *stream = stdout;
|
||||
const char *spinner[] = {_YELLOW_("[\\]"), _YELLOW_("[|]"), _YELLOW_("[/]"), _YELLOW_("[-]")};
|
||||
const char *spinner[] = {_YELLOW_("[\\]") " ", _YELLOW_("[|]") " ", _YELLOW_("[/]") " ", _YELLOW_("[-]") " "};
|
||||
const char *spinner_emoji[] = {" :clock1: ", " :clock2: ", " :clock3: ", " :clock4: ", " :clock5: ", " :clock6: ",
|
||||
" :clock7: ", " :clock8: ", " :clock9: ", " :clock10: ", " :clock11: ", " :clock12: "
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user