mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-01-09 01:36:52 +08:00
fix: tracebuffer, and messages
This commit is contained in:
parent
fd1b86d607
commit
15d258a30a
1 changed files with 19 additions and 8 deletions
|
@ -436,8 +436,13 @@ int CmdTraceList(const char *Cmd) {
|
||||||
markCRCBytes = true;
|
markCRCBytes = true;
|
||||||
cmdp++;
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
|
case '0':
|
||||||
|
isOnline = true;
|
||||||
|
cmdp++;
|
||||||
|
break;
|
||||||
case '1':
|
case '1':
|
||||||
isOnline = false;
|
isOnline = false;
|
||||||
|
cmdp++;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
|
||||||
|
@ -467,15 +472,17 @@ int CmdTraceList(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SanityOfflineCheck(isOnline)) return 1;
|
//if (!SanityOfflineCheck(isOnline)) return 1;
|
||||||
|
|
||||||
//Validations
|
//Validations
|
||||||
if (errors) return usage_trace_list();
|
if (errors) return usage_trace_list();
|
||||||
|
|
||||||
uint16_t tracepos = 0;
|
uint16_t tracepos = 0;
|
||||||
// reserv some space.
|
// reserv some space.
|
||||||
if (!trace)
|
if (!trace) {
|
||||||
|
printf("trace pointer not allocated\n");
|
||||||
trace = malloc(USB_CMD_DATA_SIZE);
|
trace = malloc(USB_CMD_DATA_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
if ( isOnline ) {
|
if ( isOnline ) {
|
||||||
// Query for the size of the trace
|
// Query for the size of the trace
|
||||||
|
@ -526,7 +533,6 @@ int CmdTraceList(const char *Cmd) {
|
||||||
tracepos = printTraceLine(tracepos, traceLen, trace, protocol, showWaitCycles, markCRCBytes);
|
tracepos = printTraceLine(tracepos, traceLen, trace, protocol, showWaitCycles, markCRCBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(trace);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +558,7 @@ int CmdTraceLoad(const char *Cmd) {
|
||||||
fseek(f, 0, SEEK_SET);
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
if (fsize < 0) {
|
if (fsize < 0) {
|
||||||
PrintAndLogEx(WARNING, "error, when getting filesize");
|
PrintAndLogEx(FAILED, "error, when getting filesize");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
@ -562,17 +568,22 @@ int CmdTraceLoad(const char *Cmd) {
|
||||||
// or we just skip this limit at all
|
// or we just skip this limit at all
|
||||||
bytes_read = fread(buf, 1, 2, f);
|
bytes_read = fread(buf, 1, 2, f);
|
||||||
if (bytes_read != 2) {
|
if (bytes_read != 2) {
|
||||||
PrintAndLogEx(FAILED, "File reading error.");
|
PrintAndLogEx(FAILED, "error, when reading dumpsize");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( trace )
|
||||||
|
free(trace);
|
||||||
|
|
||||||
|
// old dumpsize two first bytes of file
|
||||||
|
traceLen = bytes_to_num(buf, 2); // little endian in file
|
||||||
|
|
||||||
// RDV40 will have bigger traces
|
// RDV40 will have bigger traces
|
||||||
if (fsize > traceLen + 2 ){
|
if (fsize > traceLen + 2 ){
|
||||||
traceLen = fsize;
|
traceLen = fsize;
|
||||||
trace = malloc(fsize);
|
trace = malloc(fsize);
|
||||||
} else {
|
} else {
|
||||||
traceLen = bytes_to_num(buf, 2); // little endian in file
|
|
||||||
trace = malloc(traceLen+2);
|
trace = malloc(traceLen+2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,7 +595,7 @@ int CmdTraceLoad(const char *Cmd) {
|
||||||
|
|
||||||
bytes_read = fread(trace, 1, traceLen, f);
|
bytes_read = fread(trace, 1, traceLen, f);
|
||||||
if (bytes_read != traceLen) {
|
if (bytes_read != traceLen) {
|
||||||
PrintAndLogEx(FAILED, "File reading error.");
|
PrintAndLogEx(FAILED, "File reading error. %d -- %d", bytes_read, traceLen);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue