mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-21 22:03:42 -07:00
style
This commit is contained in:
parent
8f73520173
commit
f6e0b8c330
3 changed files with 78 additions and 36 deletions
|
@ -1707,7 +1707,7 @@ static int CmdSetGraphMarkers(const char *Cmd) {
|
||||||
arg_param_begin,
|
arg_param_begin,
|
||||||
arg_lit0(NULL, "keep", "keep the current values of the markers"),
|
arg_lit0(NULL, "keep", "keep the current values of the markers"),
|
||||||
arg_u64_0("a", NULL, "<dec>", "yellow marker"),
|
arg_u64_0("a", NULL, "<dec>", "yellow marker"),
|
||||||
arg_u64_0("b", NULL, "<dec>", "pink marker"),
|
arg_u64_0("b", NULL, "<dec>", "purple marker"),
|
||||||
arg_u64_0("c", NULL, "<dec>", "orange marker"),
|
arg_u64_0("c", NULL, "<dec>", "orange marker"),
|
||||||
arg_u64_0("d", NULL, "<dec>", "blue marker"),
|
arg_u64_0("d", NULL, "<dec>", "blue marker"),
|
||||||
arg_param_end
|
arg_param_end
|
||||||
|
|
|
@ -96,7 +96,9 @@ size_t ClearGraph(bool redraw) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setGraphBuffer(const uint8_t *src, size_t size) {
|
void setGraphBuffer(const uint8_t *src, size_t size) {
|
||||||
if (src == NULL) return;
|
if (src == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ClearGraph(false);
|
ClearGraph(false);
|
||||||
|
|
||||||
|
@ -121,15 +123,25 @@ size_t getFromGraphBuffer(uint8_t *dest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getFromGraphBufferEx(uint8_t *dest, size_t maxLen) {
|
size_t getFromGraphBufferEx(uint8_t *dest, size_t maxLen) {
|
||||||
if (dest == NULL) return 0;
|
if (dest == NULL){
|
||||||
if (g_GraphTraceLen == 0) return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_GraphTraceLen == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
maxLen = (maxLen < g_GraphTraceLen) ? maxLen : g_GraphTraceLen;
|
maxLen = (maxLen < g_GraphTraceLen) ? maxLen : g_GraphTraceLen;
|
||||||
for (i = 0; i < maxLen; ++i) {
|
for (i = 0; i < maxLen; ++i) {
|
||||||
//trim
|
//trim
|
||||||
if (g_GraphBuffer[i] > 127) g_GraphBuffer[i] = 127;
|
if (g_GraphBuffer[i] > 127) {
|
||||||
if (g_GraphBuffer[i] < -127) g_GraphBuffer[i] = -127;
|
g_GraphBuffer[i] = 127;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (g_GraphBuffer[i] < -127) {
|
||||||
|
g_GraphBuffer[i] = -127;
|
||||||
|
}
|
||||||
dest[i] = (uint8_t)(g_GraphBuffer[i] + 128);
|
dest[i] = (uint8_t)(g_GraphBuffer[i] + 128);
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -138,9 +150,17 @@ size_t getFromGraphBufferEx(uint8_t *dest, size_t maxLen) {
|
||||||
//TODO: In progress function to get chunks of data from the GB w/o modifying the GB
|
//TODO: In progress function to get chunks of data from the GB w/o modifying the GB
|
||||||
//Currently seems like it doesn't work correctly?
|
//Currently seems like it doesn't work correctly?
|
||||||
size_t getGraphBufferChunk(uint8_t *dest, size_t start, size_t end) {
|
size_t getGraphBufferChunk(uint8_t *dest, size_t start, size_t end) {
|
||||||
if (dest == NULL) return 0;
|
if (dest == NULL) {
|
||||||
if (g_GraphTraceLen == 0) return 0;
|
return 0;
|
||||||
if (start >= end) return 0;
|
}
|
||||||
|
|
||||||
|
if (g_GraphTraceLen == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (start >= end) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t i, value;
|
size_t i, value;
|
||||||
end = (end < g_GraphTraceLen) ? end : g_GraphTraceLen;
|
end = (end < g_GraphTraceLen) ? end : g_GraphTraceLen;
|
||||||
|
@ -186,6 +206,7 @@ void convertGraphFromBitstream(void) {
|
||||||
|
|
||||||
void convertGraphFromBitstreamEx(int hi, int low) {
|
void convertGraphFromBitstreamEx(int hi, int low) {
|
||||||
for (int i = 0; i < g_GraphTraceLen; i++) {
|
for (int i = 0; i < g_GraphTraceLen; i++) {
|
||||||
|
|
||||||
if (g_GraphBuffer[i] == hi)
|
if (g_GraphBuffer[i] == hi)
|
||||||
g_GraphBuffer[i] = 127;
|
g_GraphBuffer[i] = 127;
|
||||||
else if (g_GraphBuffer[i] == low)
|
else if (g_GraphBuffer[i] == low)
|
||||||
|
@ -215,12 +236,14 @@ void convertGraphFromBitstreamEx(int hi, int low) {
|
||||||
|
|
||||||
// Get or auto-detect ask clock rate
|
// Get or auto-detect ask clock rate
|
||||||
int GetAskClock(const char *str, bool verbose) {
|
int GetAskClock(const char *str, bool verbose) {
|
||||||
if (getSignalProperties()->isnoise)
|
if (getSignalProperties()->isnoise) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int clock1 = param_get32ex(str, 0, 0, 10);
|
int clock1 = param_get32ex(str, 0, 0, 10);
|
||||||
if (clock1 > 0)
|
if (clock1 > 0) {
|
||||||
return clock1;
|
return clock1;
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-detect clock
|
// Auto-detect clock
|
||||||
|
|
||||||
|
@ -248,16 +271,18 @@ int GetAskClock(const char *str, bool verbose) {
|
||||||
setClockGrid(clock1, idx);
|
setClockGrid(clock1, idx);
|
||||||
}
|
}
|
||||||
// Only print this message if we're not looping something
|
// Only print this message if we're not looping something
|
||||||
if (verbose || g_debugMode)
|
if (verbose || g_debugMode) {
|
||||||
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d, Best Starting Position: %d", clock1, idx);
|
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d, Best Starting Position: %d", clock1, idx);
|
||||||
|
}
|
||||||
|
|
||||||
free(bits);
|
free(bits);
|
||||||
return clock1;
|
return clock1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPskCarrier(bool verbose) {
|
int GetPskCarrier(bool verbose) {
|
||||||
if (getSignalProperties()->isnoise)
|
if (getSignalProperties()->isnoise) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||||
if (bits == NULL) {
|
if (bits == NULL) {
|
||||||
|
@ -276,23 +301,31 @@ int GetPskCarrier(bool verbose) {
|
||||||
free(bits);
|
free(bits);
|
||||||
|
|
||||||
uint8_t carrier = fc & 0xFF;
|
uint8_t carrier = fc & 0xFF;
|
||||||
if (carrier != 2 && carrier != 4 && carrier != 8) return 0;
|
if (carrier != 2 && carrier != 4 && carrier != 8) {
|
||||||
if ((fc >> 8) == 10 && carrier == 8) return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((fc >> 8) == 10 && carrier == 8) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// Only print this message if we're not looping something
|
// Only print this message if we're not looping something
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Auto-detected PSK carrier rate: %d", carrier);
|
PrintAndLogEx(SUCCESS, "Auto-detected PSK carrier rate: %d", carrier);
|
||||||
|
}
|
||||||
|
|
||||||
return carrier;
|
return carrier;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPskClock(const char *str, bool verbose) {
|
int GetPskClock(const char *str, bool verbose) {
|
||||||
|
|
||||||
if (getSignalProperties()->isnoise)
|
if (getSignalProperties()->isnoise) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int clock1 = param_get32ex(str, 0, 0, 10);
|
int clock1 = param_get32ex(str, 0, 0, 10);
|
||||||
if (clock1 != 0)
|
if (clock1 != 0) {
|
||||||
return clock1;
|
return clock1;
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-detect clock
|
// Auto-detect clock
|
||||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||||
|
@ -312,12 +345,14 @@ int GetPskClock(const char *str, bool verbose) {
|
||||||
uint8_t curPhase = 0, fc = 0;
|
uint8_t curPhase = 0, fc = 0;
|
||||||
clock1 = DetectPSKClock(bits, size, 0, &firstPhaseShiftLoc, &curPhase, &fc);
|
clock1 = DetectPSKClock(bits, size, 0, &firstPhaseShiftLoc, &curPhase, &fc);
|
||||||
|
|
||||||
if (clock1 >= 0)
|
if (clock1 >= 0) {
|
||||||
setClockGrid(clock1, firstPhaseShiftLoc);
|
setClockGrid(clock1, firstPhaseShiftLoc);
|
||||||
|
}
|
||||||
|
|
||||||
// Only print this message if we're not looping something
|
// Only print this message if we're not looping something
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d", clock1);
|
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d", clock1);
|
||||||
|
}
|
||||||
|
|
||||||
free(bits);
|
free(bits);
|
||||||
return clock1;
|
return clock1;
|
||||||
|
@ -325,12 +360,14 @@ int GetPskClock(const char *str, bool verbose) {
|
||||||
|
|
||||||
int GetNrzClock(const char *str, bool verbose) {
|
int GetNrzClock(const char *str, bool verbose) {
|
||||||
|
|
||||||
if (getSignalProperties()->isnoise)
|
if (getSignalProperties()->isnoise) {
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
int clock1 = param_get32ex(str, 0, 0, 10);
|
int clock1 = param_get32ex(str, 0, 0, 10);
|
||||||
if (clock1 != 0)
|
if (clock1 != 0) {
|
||||||
return clock1;
|
return clock1;
|
||||||
|
}
|
||||||
|
|
||||||
// Auto-detect clock
|
// Auto-detect clock
|
||||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||||
|
@ -350,8 +387,9 @@ int GetNrzClock(const char *str, bool verbose) {
|
||||||
clock1 = DetectNRZClock(bits, size, 0, &clkStartIdx);
|
clock1 = DetectNRZClock(bits, size, 0, &clkStartIdx);
|
||||||
setClockGrid(clock1, clkStartIdx);
|
setClockGrid(clock1, clkStartIdx);
|
||||||
// Only print this message if we're not looping something
|
// Only print this message if we're not looping something
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d", clock1);
|
PrintAndLogEx(SUCCESS, "Auto-detected clock rate: %d", clock1);
|
||||||
|
}
|
||||||
|
|
||||||
free(bits);
|
free(bits);
|
||||||
return clock1;
|
return clock1;
|
||||||
|
@ -362,18 +400,21 @@ int GetNrzClock(const char *str, bool verbose) {
|
||||||
int GetFskClock(const char *str, bool verbose) {
|
int GetFskClock(const char *str, bool verbose) {
|
||||||
|
|
||||||
int clock1 = param_get32ex(str, 0, 0, 10);
|
int clock1 = param_get32ex(str, 0, 0, 10);
|
||||||
if (clock1 != 0)
|
if (clock1 != 0) {
|
||||||
return clock1;
|
return clock1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t fc1 = 0, fc2 = 0, rf1 = 0;
|
uint8_t fc1 = 0, fc2 = 0, rf1 = 0;
|
||||||
int firstClockEdge = 0;
|
int firstClockEdge = 0;
|
||||||
|
|
||||||
if (fskClocks(&fc1, &fc2, &rf1, &firstClockEdge) == false)
|
if (fskClocks(&fc1, &fc2, &rf1, &firstClockEdge) == false) {
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5)) {
|
if ((fc1 == 10 && fc2 == 8) || (fc1 == 8 && fc2 == 5)) {
|
||||||
if (verbose)
|
if (verbose) {
|
||||||
PrintAndLogEx(SUCCESS, "Detected Field Clocks: FC/%d, FC/%d - Bit Clock: RF/%d", fc1, fc2, rf1);
|
PrintAndLogEx(SUCCESS, "Detected Field Clocks: FC/%d, FC/%d - Bit Clock: RF/%d", fc1, fc2, rf1);
|
||||||
|
}
|
||||||
|
|
||||||
setClockGrid(rf1, firstClockEdge);
|
setClockGrid(rf1, firstClockEdge);
|
||||||
return rf1;
|
return rf1;
|
||||||
|
@ -386,8 +427,9 @@ int GetFskClock(const char *str, bool verbose) {
|
||||||
|
|
||||||
bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) {
|
bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge) {
|
||||||
|
|
||||||
if (getSignalProperties()->isnoise)
|
if (getSignalProperties()->isnoise) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||||
if (bits == NULL) {
|
if (bits == NULL) {
|
||||||
|
@ -429,13 +471,13 @@ buffer_savestate_t save_buffer32(uint32_t *src, size_t length) {
|
||||||
//Make a copy of the source buffer
|
//Make a copy of the source buffer
|
||||||
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
|
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
|
||||||
|
|
||||||
buffer_savestate_t tommy = {
|
buffer_savestate_t bst = {
|
||||||
.type = sizeof(uint32_t),
|
.type = sizeof(uint32_t),
|
||||||
.bufferSize = length,
|
.bufferSize = length,
|
||||||
.buffer = savedBuffer
|
.buffer = savedBuffer
|
||||||
};
|
};
|
||||||
|
|
||||||
return tommy;
|
return bst;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_savestate_t save_bufferS32(int32_t *src, size_t length) {
|
buffer_savestate_t save_bufferS32(int32_t *src, size_t length) {
|
||||||
|
@ -445,13 +487,13 @@ buffer_savestate_t save_bufferS32(int32_t *src, size_t length) {
|
||||||
//Make a copy of the source buffer
|
//Make a copy of the source buffer
|
||||||
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
|
memcpy(savedBuffer, src, (length * sizeof(uint32_t)));
|
||||||
|
|
||||||
buffer_savestate_t billy = {
|
buffer_savestate_t bst = {
|
||||||
.type = (sizeof(int32_t) >> 8),
|
.type = (sizeof(int32_t) >> 8),
|
||||||
.bufferSize = length,
|
.bufferSize = length,
|
||||||
.buffer = savedBuffer
|
.buffer = savedBuffer
|
||||||
};
|
};
|
||||||
|
|
||||||
return billy;
|
return bst;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
|
buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
|
||||||
|
@ -471,13 +513,13 @@ buffer_savestate_t save_buffer8(uint8_t *src, size_t length) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer_savestate_t timmy = {
|
buffer_savestate_t bst = {
|
||||||
.type = sizeof(uint8_t),
|
.type = sizeof(uint8_t),
|
||||||
.bufferSize = buffSize,
|
.bufferSize = buffSize,
|
||||||
.buffer = savedBuffer
|
.buffer = savedBuffer
|
||||||
};
|
};
|
||||||
|
|
||||||
return timmy;
|
return bst;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t restore_buffer32(buffer_savestate_t saveState, uint32_t *dest) {
|
size_t restore_buffer32(buffer_savestate_t saveState, uint32_t *dest) {
|
||||||
|
|
|
@ -1380,7 +1380,7 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Shift") " + " _YELLOW_("Mouse wheel"), "Zoom in/out around mouse cursor");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Shift") " + " _YELLOW_("Mouse wheel"), "Zoom in/out around mouse cursor");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Down") "/" _RED_("Up"), "Zoom in/out around yellow marker");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("Down") "/" _RED_("Up"), "Zoom in/out around yellow marker");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... with smaller increment");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... with smaller increment");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Shift"), "... around pink marker");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Shift"), "... around purple marker");
|
||||||
PrintAndLogEx(NORMAL, "\n" _GREEN_("Trim:"));
|
PrintAndLogEx(NORMAL, "\n" _GREEN_("Trim:"));
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("t"), "Trim data on window or on markers (if defined)");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _RED_("t"), "Trim data on window or on markers (if defined)");
|
||||||
PrintAndLogEx(NORMAL, "\n" _GREEN_("Grid and demod:"));
|
PrintAndLogEx(NORMAL, "\n" _GREEN_("Grid and demod:"));
|
||||||
|
@ -1389,9 +1389,9 @@ void Plot::keyPressEvent(QKeyEvent *event) {
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("< ") "/" _RED_(" >"), "Move demodulation left/right relative to samples");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("< ") "/" _RED_(" >"), "Move demodulation left/right relative to samples");
|
||||||
PrintAndLogEx(NORMAL, "\n" _GREEN_("Misc:"));
|
PrintAndLogEx(NORMAL, "\n" _GREEN_("Misc:"));
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Left mouse click"), "Set yellow marker");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Left mouse click"), "Set yellow marker");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Right mouse click"), "Set pink marker");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, _YELLOW_("Right mouse click"), "Set purple marker");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("[ ") "/" _RED_(" ]"), "Move yellow marker left/right by 1 sample");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("[ ") "/" _RED_(" ]"), "Move yellow marker left/right by 1 sample");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("{ ") "/" _RED_(" }"), "Move pink marker left/right by 1 sample");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("{ ") "/" _RED_(" }"), "Move purple marker left/right by 1 sample");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5 samples");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5 samples");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point (Operation Buffer) over the yellow marker by 1");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9 + 9, _RED_("= ") "/" _RED_(" -"), "Add/Subtract to the plot point (Operation Buffer) over the yellow marker by 1");
|
||||||
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5");
|
PrintAndLogEx(NORMAL, " %-*s%s", 25 + 9, " + " _RED_("Ctrl"), "... by 5");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue