\r
for(i = 0; i < GraphTraceLen; i++) {\r
if(GraphBuffer[i]>= threshold)\r
- GraphBuffer[i]=127;\r
+ GraphBuffer[i]=1;\r
else\r
- GraphBuffer[i]=-128;\r
+ GraphBuffer[i]=-1;\r
}\r
RepaintGraphWindow();\r
}\r
ShowGraphWindow();\r
}\r
\r
+static void CmdGrid(char *str)\r
+{\r
+ int x = 0, y = 0;\r
+ sscanf(str, "%i %i", &x, &y);\r
+ SetGraphGrid(x, y);\r
+ RepaintGraphWindow();\r
+}\r
+\r
static void CmdHide(char *str)\r
{\r
HideGraphWindow();\r
}\r
}\r
\r
-\r
-\r
-static void CmdTest(char *str)\r
-{\r
-}\r
-\r
/*\r
* Sets the divisor for LF frequency clock: lets the user choose any LF frequency below\r
* 600kHz.\r
int offline; // 1 if the command can be used when in offline mode\r
char *docString;\r
} CommandTable[] = {\r
- {"askdemod", Cmdaskdemod,1, "<samples per bit> <0|1> -- Attempt to demodulate simple ASK tags"},\r
- {"autocorr", CmdAutoCorr,1, "<window length> -- Autocorrelation over window"},\r
- {"bitsamples", CmdBitsamples,0, " Get raw samples as bitstring"},\r
- {"bitstream", Cmdbitstream,1, "[clock rate] -- Convert waveform into a bitstream"},\r
- {"buffclear", CmdBuffClear,0, " Clear sample buffer and graph window"},\r
- {"dec", CmdDec,1, " Decimate samples"},\r
- {"detectclock", Cmddetectclockrate,1, " Detect clock rate"},\r
- {"detectreader", CmdDetectReader,0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},\r
- {"em410xsim", CmdEM410xsim,1, "<UID> -- Simulate EM410x tag"},\r
- {"em410xread", CmdEM410xread,1, "[clock rate] -- Extract ID from EM410x tag"},\r
- {"em410xwatch", CmdEM410xwatch,0, " Watches for EM410x tags"},\r
- {"em4x50read", CmdEM4x50read,1, " Extract data from EM4x50 tag"},\r
- {"exit", CmdQuit,1, " Exit program"},\r
- {"flexdemod", CmdFlexdemod,1, " Demodulate samples for FlexPass"},\r
- {"fpgaoff", CmdFPGAOff,0, " Set FPGA off"}, // ## FPGA Control\r
- {"fskdemod", CmdFSKdemod,1, " Demodulate graph window as a HID FSK"},\r
- {"hexsamples", CmdHexsamples,0, "<blocks> -- Dump big buffer as hex bytes"},\r
- {"hi14alist", CmdHi14alist,0, " List ISO 14443a history"}, // ## New list command\r
- {"hi14areader", CmdHi14areader,0, " Act like an ISO14443 Type A reader"}, // ## New reader command\r
- {"hi14asim", CmdHi14asim,0, "<UID> -- Fake ISO 14443a tag"}, // ## Simulate 14443a tag\r
- {"hi14asnoop", CmdHi14asnoop,0, " Eavesdrop ISO 14443 Type A"}, // ## New snoop command\r
- {"hi14bdemod", CmdHi14bdemod,1, " Demodulate ISO14443 Type B from tag"},\r
- {"hi14list", CmdHi14list,0, " List ISO 14443 history"},\r
- {"hi14read", CmdHi14read,0, " Read HF tag (ISO 14443)"},\r
- {"hi14sim", CmdHi14sim,0, " Fake ISO 14443 tag"},\r
- {"hi14snoop", CmdHi14snoop,0, " Eavesdrop ISO 14443"},\r
- {"hi15demod", CmdHi15demod,1, " Demodulate ISO15693 from tag"},\r
- {"hi15read", CmdHi15read,0, " Read HF tag (ISO 15693)"},\r
- {"hi15reader", CmdHi15reader,0, " Act like an ISO15693 reader"}, // new command greg\r
- {"hi15sim", CmdHi15tag,0, " Fake an ISO15693 tag"}, // new command greg\r
- {"hiddemod", CmdHiddemod,1, " Demodulate HID Prox Card II (not optimal)"},\r
- {"hide", CmdHide,1, " Hide graph window"},\r
- {"hidfskdemod", CmdHIDdemodFSK,0, " Realtime HID FSK demodulator"},\r
- {"hidsimtag", CmdHIDsimTAG,0, "<ID> -- HID tag simulator"},\r
- {"higet", CmdHi14read_sim,0, "<samples> -- Get samples HF, 'analog'"},\r
- {"hisamples", CmdHisamples,0, " Get raw samples for HF tag"},\r
- {"hisampless", CmdHisampless,0, "<samples> -- Get signed raw samples, HF tag"},\r
- {"hisamplest", CmdHi14readt,0, " Get samples HF, for testing"},\r
- {"hisimlisten", CmdHisimlisten,0, " Get HF samples as fake tag"},\r
- {"hpf", CmdHpf,1, " Remove DC offset from trace"},\r
- {"indalademod", CmdIndalademod,0, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},\r
- {"lcd", CmdLcd,0, "<HEX command> <count> -- Send command/data to LCD"},\r
- {"lcdreset", CmdLcdReset,0, " Hardware reset LCD"},\r
- {"load", CmdLoad,1, "<filename> -- Load trace (to graph window"},\r
- {"locomread", CmdLoCommandRead,0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},\r
- {"loread", CmdLoread,0, "['h'] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134)"},\r
- {"losamples", CmdLosamples,0, "[128 - 16000] -- Get raw samples for LF tag"},\r
- {"losim", CmdLosim,0, " Simulate LF tag"},\r
- {"ltrim", CmdLtrim,1, "<samples> -- Trim samples from left of trace"},\r
- {"mandemod", Cmdmanchesterdemod,1, "[i] [clock rate] -- Manchester demodulate binary stream (option 'i' to invert output)"},\r
- {"manmod", Cmdmanchestermod,1, "[clock rate] -- Manchester modulate a binary stream"},\r
- {"norm", CmdNorm,1, " Normalize max/min to +/-500"},\r
- {"plot", CmdPlot,1, " Show graph window"},\r
- {"quit", CmdQuit,1, " Quit program"},\r
- {"readmem", CmdReadmem,0, " [address] -- Read memory at decimal address from flash"},\r
- {"reset", CmdReset,0, " Reset the Proxmark3"},\r
- {"save", CmdSave,1, "<filename> -- Save trace (from graph window)"},\r
- {"scale", CmdScale,1, "<int> -- Set cursor display scale"},\r
- {"setlfdivisor", CmdSetDivisor,0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},\r
- {"sri512read", CmdSri512read,0, "<int> -- Read contents of a SRI512 tag"},\r
- {"tibits", CmdTibits,0, " Get raw bits for TI-type LF tag"},\r
- {"tidemod", CmdTidemod,1, " Demodulate raw bits for TI-type LF tag"},\r
- {"tiread", CmdTiread,0, " Read a TI-type 134 kHz tag"},\r
- {"threshold", CmdThreshold,1, " Maximize/minimize every value in the graph window depending on threshold"},\r
- {"tune", CmdTune,0, " Measure antenna tuning"},\r
- {"vchdemod", CmdVchdemod,0, "['clone'] -- Demodulate samples for VeriChip"},\r
- {"zerocrossings", CmdZerocrossings,1, " Count time between zero-crossings"},\r
+ {"askdemod", Cmdaskdemod, 1, "<samples per bit> <0|1> -- Attempt to demodulate simple ASK tags"},\r
+ {"autocorr", CmdAutoCorr, 1, "<window length> -- Autocorrelation over window"},\r
+ {"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"},\r
+ {"bitstream", Cmdbitstream, 1, "[clock rate] -- Convert waveform into a bitstream"},\r
+ {"buffclear", CmdBuffClear, 0, "Clear sample buffer and graph window"},\r
+ {"dec", CmdDec, 1, "Decimate samples"},\r
+ {"detectclock", Cmddetectclockrate, 1, "Detect clock rate"},\r
+ {"detectreader", CmdDetectReader, 0, "['l'|'h'] -- Detect external reader field (option 'l' or 'h' to limit to LF or HF)"},\r
+ {"em410xsim", CmdEM410xsim, 1, "<UID> -- Simulate EM410x tag"},\r
+ {"em410xread", CmdEM410xread, 1, "[clock rate] -- Extract ID from EM410x tag"},\r
+ {"em410xwatch", CmdEM410xwatch, 0, "Watches for EM410x tags"},\r
+ {"em4x50read", CmdEM4x50read, 1, "Extract data from EM4x50 tag"},\r
+ {"exit", CmdQuit, 1, "Exit program"},\r
+ {"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},\r
+ {"fpgaoff", CmdFPGAOff, 0, "Set FPGA off"},\r
+ {"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"},\r
+ {"grid", CmdGrid, 1, "grid x y, overlay grid on graph window, use zero value to turn off either"},\r
+ {"hexsamples", CmdHexsamples, 0, "<blocks> -- Dump big buffer as hex bytes"},\r
+ {"hi14alist", CmdHi14alist, 0, "List ISO 14443a history"},\r
+ {"hi14areader", CmdHi14areader, 0, "Act like an ISO14443 Type A reader"},\r
+ {"hi14asim", CmdHi14asim, 0, "<UID> -- Fake ISO 14443a tag"},\r
+ {"hi14asnoop", CmdHi14asnoop, 0, "Eavesdrop ISO 14443 Type A"},\r
+ {"hi14bdemod", CmdHi14bdemod, 1, "Demodulate ISO14443 Type B from tag"},\r
+ {"hi14list", CmdHi14list, 0, "List ISO 14443 history"},\r
+ {"hi14read", CmdHi14read, 0, "Read HF tag (ISO 14443)"},\r
+ {"hi14sim", CmdHi14sim, 0, "Fake ISO 14443 tag"},\r
+ {"hi14snoop", CmdHi14snoop, 0, "Eavesdrop ISO 14443"},\r
+ {"hi15demod", CmdHi15demod, 1, "Demodulate ISO15693 from tag"},\r
+ {"hi15read", CmdHi15read, 0, "Read HF tag (ISO 15693)"},\r
+ {"hi15reader", CmdHi15reader, 0, "Act like an ISO15693 reader"},\r
+ {"hi15sim", CmdHi15tag, 0, "Fake an ISO15693 tag"},\r
+ {"hiddemod", CmdHiddemod, 1, "Demodulate HID Prox Card II (not optimal)"},\r
+ {"hide", CmdHide, 1, "Hide graph window"},\r
+ {"hidfskdemod", CmdHIDdemodFSK, 0, "Realtime HID FSK demodulator"},\r
+ {"hidsimtag", CmdHIDsimTAG, 0, "<ID> -- HID tag simulator"},\r
+ {"higet", CmdHi14read_sim, 0, "<samples> -- Get samples HF, 'analog'"},\r
+ {"hisamples", CmdHisamples, 0, "Get raw samples for HF tag"},\r
+ {"hisampless", CmdHisampless, 0, "<samples> -- Get signed raw samples, HF tag"},\r
+ {"hisamplest", CmdHi14readt, 0, "Get samples HF, for testing"},\r
+ {"hisimlisten", CmdHisimlisten, 0, "Get HF samples as fake tag"},\r
+ {"hpf", CmdHpf, 1, "Remove DC offset from trace"},\r
+ {"indalademod", CmdIndalademod, 0, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},\r
+ {"lcd", CmdLcd, 0, "<HEX command> <count> -- Send command/data to LCD"},\r
+ {"lcdreset", CmdLcdReset, 0, "Hardware reset LCD"},\r
+ {"load", CmdLoad, 1, "<filename> -- Load trace (to graph window"},\r
+ {"locomread", CmdLoCommandRead, 0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},\r
+ {"loread", CmdLoread, 0, "['h'] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134)"},\r
+ {"losamples", CmdLosamples, 0, "[128 - 16000] -- Get raw samples for LF tag"},\r
+ {"losim", CmdLosim, 0, "Simulate LF tag"},\r
+ {"ltrim", CmdLtrim, 1, "<samples> -- Trim samples from left of trace"},\r
+ {"mandemod", Cmdmanchesterdemod, 1, "[i] [clock rate] -- Manchester demodulate binary stream (option 'i' to invert output)"},\r
+ {"manmod", Cmdmanchestermod, 1, "[clock rate] -- Manchester modulate a binary stream"},\r
+ {"norm", CmdNorm, 1, "Normalize max/min to +/-500"},\r
+ {"plot", CmdPlot, 1, "Show graph window"},\r
+ {"quit", CmdQuit, 1, "Quit program"},\r
+ {"readmem", CmdReadmem, 0, "[address] -- Read memory at decimal address from flash"},\r
+ {"reset", CmdReset, 0, "Reset the Proxmark3"},\r
+ {"save", CmdSave, 1, "<filename> -- Save trace (from graph window)"},\r
+ {"scale", CmdScale, 1, "<int> -- Set cursor display scale"},\r
+ {"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},\r
+ {"sri512read", CmdSri512read, 0, "<int> -- Read contents of a SRI512 tag"},\r
+ {"tibits", CmdTibits, 0, "Get raw bits for TI-type LF tag"},\r
+ {"tidemod", CmdTidemod, 1, "Demodulate raw bits for TI-type LF tag"},\r
+ {"tiread", CmdTiread, 0, "Read a TI-type 134 kHz tag"},\r
+ {"threshold", CmdThreshold, 1, "Maximize/minimize every value in the graph window depending on threshold"},\r
+ {"tune", CmdTune, 0, "Measure antenna tuning"},\r
+ {"vchdemod", CmdVchdemod, 0, "['clone'] -- Demodulate samples for VeriChip"},\r
+ {"zerocrossings", CmdZerocrossings, 1, "Count time between zero-crossings"},\r
};\r
\r
static struct {\r
int GraphBuffer[MAX_GRAPH_TRACE_LEN];\r
int GraphTraceLen;\r
\r
-HPEN GreyPen, GreenPen, WhitePen, YellowPen;\r
+HPEN GreyPenLite, GreyPen, GreenPen, WhitePen, YellowPen;\r
HBRUSH GreenBrush, YellowBrush;\r
\r
static int GraphStart = 0;\r
static double GraphPixelsPerPoint = 1;\r
\r
+static int PlotGridX = 0, PlotGridY = 0;\r
static int CursorAPos;\r
static int CursorBPos;\r
double CursorScaleFactor = 1.0;\r
\r
void ExecCmd(char *cmd)\r
{\r
-\r
}\r
+\r
int CommandFinished;\r
int offset = 64;\r
\r
+void SetGraphGrid(int x, int y)\r
+{\r
+ PlotGridX = x;\r
+ PlotGridY = y;\r
+}\r
+\r
static void ResizeCommandWindow(void)\r
{\r
int w, h;\r
\r
static void PaintGraph(HDC hdc)\r
{\r
+ RECT r;\r
HBRUSH brush;\r
HPEN pen;\r
+ char str[250];\r
+ int yMin = INT_MAX;\r
+ int yMax = INT_MIN;\r
+ int yMean = 0;\r
+ int startMax = 0;\r
+ int absYMax = 1;\r
+ int n = 0, i = 0;\r
\r
brush = GreenBrush;\r
pen = GreenPen;\r
\r
- if(GraphStart < 0) {\r
- GraphStart = 0;\r
- }\r
-\r
- RECT r;\r
GetClientRect(GraphWindow, &r);\r
+ int zeroHeight = (r.top + r.bottom) >> 1;\r
+\r
+ // plot X and Y grid lines\r
+ if ((PlotGridX > 0) && ((PlotGridX * GraphPixelsPerPoint) > 1)) {\r
+ for(i = offset; i < r.right; i += (int)(PlotGridX * GraphPixelsPerPoint)) {\r
+ SelectObject(hdc, GreyPenLite);\r
+ MoveToEx(hdc, r.left + i, r.top, NULL);\r
+ LineTo(hdc, r.left + i, r.bottom);\r
+ }\r
+ }\r
+\r
+ if ((PlotGridY > 0) && ((PlotGridY * GraphPixelsPerPoint) > 1)){\r
+ for(i = 0; i < ((r.top + r.bottom)>>1); i += (int)(PlotGridY * GraphPixelsPerPoint)) {\r
+ SelectObject(hdc, GreyPenLite);\r
+ MoveToEx(hdc, r.left, zeroHeight + i, NULL);\r
+ LineTo(hdc, r.right, zeroHeight + i);\r
+ MoveToEx(hdc, r.left, zeroHeight - i, NULL);\r
+ LineTo(hdc, r.right, zeroHeight - i);\r
+ }\r
+ }\r
\r
+ // print vertical separator white line on the left of the window\r
SelectObject(hdc, WhitePen);\r
-\r
MoveToEx(hdc, r.left + offset, r.top, NULL);\r
LineTo(hdc, r.left + offset, r.bottom);\r
\r
- int zeroHeight = r.top + (r.bottom - r.top) / 2;\r
+ // print horizontal grey zero axis line\r
SelectObject(hdc, GreyPen);\r
MoveToEx(hdc, r.left, zeroHeight, NULL);\r
LineTo(hdc, r.right, zeroHeight);\r
\r
- int startMax =\r
- (GraphTraceLen - (int)((r.right - r.left - offset) / GraphPixelsPerPoint));\r
- if(startMax < 0) {\r
- startMax = 0;\r
- }\r
- if(GraphStart > startMax) {\r
- GraphStart = startMax;\r
- }\r
+ startMax = (GraphTraceLen - (int)((r.right - r.left - offset) / GraphPixelsPerPoint));\r
+ // check boundaries\r
+ if(startMax < 0) startMax = 0;\r
+ if(GraphStart > startMax) GraphStart = startMax;\r
+ if(GraphStart < 0) GraphStart = 0;\r
\r
- int absYMax = 1;\r
\r
SelectObject(hdc, pen);\r
\r
- int i;\r
+ // go over the portion of the graph to be displayed and find the largest\r
+ // absolute value which will be used to auto scale the graph when displayed\r
for(i = GraphStart; ; i++) {\r
if(i >= GraphTraceLen) {\r
break;\r
if(pointsPerLabel <= 0) pointsPerLabel = 1;\r
pointsPerLabel = (int)pow(2.0,pointsPerLabel);\r
\r
- int yMin = INT_MAX;\r
- int yMax = INT_MIN;\r
- int yMean = 0;\r
- int n = 0;\r
-\r
+ // go over the graph and plot samples and labels\r
for(i = GraphStart; ; i++) {\r
if(i >= GraphTraceLen) {\r
break;\r
}\r
\r
int y = GraphBuffer[i];\r
- if(y < yMin) {\r
- yMin = y;\r
- }\r
- if(y > yMax) {\r
- yMax = y;\r
- }\r
+ if(y < yMin) yMin = y;\r
+ if(y > yMax) yMax = y;\r
yMean += y;\r
n++;\r
\r
FillRect(hdc, &f, brush);\r
}\r
\r
+ // plot labels\r
if(((i - GraphStart) % pointsPerLabel == 0) && i != GraphStart) {\r
SelectObject(hdc, WhitePen);\r
MoveToEx(hdc, x, zeroHeight - 8, NULL);\r
LineTo(hdc, x, zeroHeight + 8);\r
\r
- char str[100];\r
- sprintf(str, "+%d", (i - GraphStart));\r
+ sprintf(str, "+%d", i);\r
SIZE size;\r
GetTextExtentPoint32(hdc, str, strlen(str), &size);\r
TextOut(hdc, x - size.cx, zeroHeight + 8, str, strlen(str));\r
MoveToEx(hdc, x, y, NULL);\r
}\r
\r
+ // plot measurement cursors\r
if(i == CursorAPos || i == CursorBPos) {\r
if(i == CursorAPos) {\r
SelectObject(hdc, CursorAPen);\r
yMean /= n;\r
}\r
\r
- char str[200];\r
-\r
+ // print misc information at bottom of graph window\r
sprintf(str, "@%d max=%d min=%d mean=%d n=%d/%d dt=%d [%.3f] zoom=%.3f CursorA=%d [%d] CursorB=%d [%d]",\r
GraphStart, yMax, yMin, yMean, n, GraphTraceLen,\r
CursorBPos - CursorAPos, (CursorBPos - CursorAPos)/CursorScaleFactor, GraphPixelsPerPoint,\r
PrintToScrollback(">> Started prox, built " __DATE__ " " __TIME__);\r
PrintToScrollback(">> Connected to device");\r
\r
+ GreyPenLite = CreatePen(PS_SOLID, 1, RGB(50, 50, 50));\r
GreyPen = CreatePen(PS_SOLID, 1, RGB(100, 100, 100));\r
GreenPen = CreatePen(PS_SOLID, 1, RGB(100, 255, 100));\r
YellowPen = CreatePen(PS_SOLID, 1, RGB(255, 255, 0));\r