mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 15:56:21 +08:00
data scale: use cliparser and add unit string
This commit is contained in:
parent
7009f2ade7
commit
2d15fde0a8
|
@ -50,20 +50,6 @@ static int usage_data_save(void) {
|
|||
PrintAndLogEx(NORMAL, " data save f mytrace w - save graphbuffer to wave file");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_data_scale(void) {
|
||||
PrintAndLogEx(NORMAL, "Set cursor display scale.");
|
||||
PrintAndLogEx(NORMAL, "Setting the scale makes the differential `dt` reading between the yellow and purple markers meaningful. ");
|
||||
PrintAndLogEx(NORMAL, "once the scale is set, the differential reading between brackets is the time duration in seconds.");
|
||||
PrintAndLogEx(NORMAL, "For example, if acquiring in 125kHz, use scale 125.");
|
||||
PrintAndLogEx(NORMAL, "");
|
||||
PrintAndLogEx(NORMAL, "Usage: data scale [h] <kHz>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
PrintAndLogEx(NORMAL, " h this help");
|
||||
PrintAndLogEx(NORMAL, " <kHz> sets scale of carrier frequency expressed in kHz");
|
||||
PrintAndLogEx(NORMAL, "Samples:");
|
||||
PrintAndLogEx(NORMAL, " data scale 125 - if sampled in 125kHz");
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
static int usage_data_printdemodbuf(void) {
|
||||
PrintAndLogEx(NORMAL, "Usage: data printdemodbuffer x o <offset> l <length>");
|
||||
PrintAndLogEx(NORMAL, "Options:");
|
||||
|
@ -1913,14 +1899,32 @@ int CmdSave(const char *Cmd) {
|
|||
}
|
||||
|
||||
static int CmdScale(const char *Cmd) {
|
||||
char cmdp = tolower(param_getchar(Cmd, 0));
|
||||
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_data_scale();
|
||||
|
||||
CursorScaleFactor = atoi(Cmd);
|
||||
CLIParserContext *ctx;
|
||||
CLIParserInit(&ctx, "data scale",
|
||||
"Set cursor display scale.\n"
|
||||
"Setting the scale makes the differential `dt` reading between the yellow and purple markers meaningful.\n"
|
||||
"once the scale is set, the differential reading between brackets can become a time duration.",
|
||||
"data scale --sr 125 -u ms -> if sampled in 125 kHz, reading will be in milliseconds\n"
|
||||
"data scale --sr 1.695 -u us -> if HF, sampling is 1.695 MHz. Reading will be in microseconds\n"
|
||||
"data scale --sr 16 -u ETU -> if HF, 16 samples per ETU. Reading will be in ETUs"
|
||||
);
|
||||
void *argtable[] = {
|
||||
arg_param_begin,
|
||||
arg_dbl1(NULL, "sr", "<float>", "sets scale according to sampling rate"),
|
||||
arg_str0("u", "unit", "<string>", "time unit to display (max 10 chars)"),
|
||||
arg_param_end
|
||||
};
|
||||
CLIExecWithReturn(ctx, Cmd, argtable, false);
|
||||
CursorScaleFactor = arg_get_dbl_def(ctx, 1, 0);
|
||||
if (CursorScaleFactor == 0) {
|
||||
PrintAndLogEx(FAILED, "bad, can't have zero scale");
|
||||
CursorScaleFactor = 1;
|
||||
}
|
||||
int len = 0;
|
||||
CursorScaleFactorUint[0] = '\x00';
|
||||
CLIParamStrToBuf(arg_get_str(ctx, 2), (uint8_t*)CursorScaleFactorUint, sizeof(CursorScaleFactorUint), &len);
|
||||
CLIParserFree(ctx);
|
||||
RepaintGraphWindow();
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ void InitGraphics(int argc, char **argv, char *script_cmds_file, char *script_cm
|
|||
void ExitGraphics(void);
|
||||
|
||||
extern double CursorScaleFactor;
|
||||
extern char CursorScaleFactorUint[11];
|
||||
extern int PlotGridX, PlotGridY, PlotGridXdefault, PlotGridYdefault, GridOffset;
|
||||
extern uint32_t CursorCPos, CursorDPos;
|
||||
extern int CommandFinished;
|
||||
|
|
|
@ -596,10 +596,11 @@ void Plot::paintEvent(QPaintEvent *event) {
|
|||
|
||||
//Draw annotations
|
||||
char str[200];
|
||||
sprintf(str, "@%u dt=%u [%2.2f] zoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d",
|
||||
sprintf(str, "@%u dt=%i [%2.2f %s] zoom=%2.2f CursorAPos=%u CursorBPos=%u GridX=%d GridY=%d (%s) GridXoffset=%d",
|
||||
GraphStart,
|
||||
CursorBPos - CursorAPos,
|
||||
((int32_t)(CursorBPos - CursorAPos)) / CursorScaleFactor,
|
||||
CursorScaleFactorUint,
|
||||
GraphPixelsPerPoint,
|
||||
CursorAPos,
|
||||
CursorBPos,
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
session_arg_t session;
|
||||
|
||||
double CursorScaleFactor = 1;
|
||||
char CursorScaleFactorUint[11] = {0};
|
||||
int PlotGridX = 0, PlotGridY = 0, PlotGridXdefault = 64, PlotGridYdefault = 64;
|
||||
uint32_t CursorCPos = 0, CursorDPos = 0;
|
||||
double GraphPixelsPerPoint = 1.f; // How many visual pixels are between each sample point (x axis)
|
||||
|
|
Loading…
Reference in a new issue