mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-21 12:37:21 +08:00
cmddata.c changes by others - reapply
i overwrote some changes in cmdsamples. i fixed that i also removed some comments in graph.c
This commit is contained in:
parent
3179383f85
commit
d6d20c5435
2 changed files with 15 additions and 79 deletions
|
@ -932,35 +932,6 @@ int CmdIndalaDecode(const char *Cmd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
//by marshmellow (attempt to get rid of high immediately after a low)
|
|
||||||
void pskCleanWave2(uint8_t *bitStream, int bitLen)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
int low=128;
|
|
||||||
int gap = 4;
|
|
||||||
// int loopMax = 2048;
|
|
||||||
int newLow=0;
|
|
||||||
|
|
||||||
for (i=0; i<bitLen; ++i)
|
|
||||||
if (bitStream[i]<low) low=bitStream[i];
|
|
||||||
|
|
||||||
low = (int)(((low-128)*.80)+128);
|
|
||||||
PrintAndLog("low: %d",low);
|
|
||||||
for (i=0; i<bitLen; ++i){
|
|
||||||
if (newLow==1){
|
|
||||||
bitStream[i]=low+5;
|
|
||||||
gap--;
|
|
||||||
if (gap==0){
|
|
||||||
newLow=0;
|
|
||||||
gap=4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bitStream[i]<=low) newLow=1;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
int CmdPskClean(const char *Cmd)
|
int CmdPskClean(const char *Cmd)
|
||||||
{
|
{
|
||||||
uint8_t bitStream[MAX_GRAPH_TRACE_LEN]={0};
|
uint8_t bitStream[MAX_GRAPH_TRACE_LEN]={0};
|
||||||
|
@ -989,8 +960,6 @@ int CmdpskNRZrawDemod(const char *Cmd)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int CmdGrid(const char *Cmd)
|
int CmdGrid(const char *Cmd)
|
||||||
{
|
{
|
||||||
sscanf(Cmd, "%i %i", &PlotGridX, &PlotGridY);
|
sscanf(Cmd, "%i %i", &PlotGridX, &PlotGridY);
|
||||||
|
@ -1066,22 +1035,21 @@ int CmdHpf(const char *Cmd)
|
||||||
|
|
||||||
int CmdSamples(const char *Cmd)
|
int CmdSamples(const char *Cmd)
|
||||||
{
|
{
|
||||||
int cnt = 0;
|
|
||||||
int n;
|
|
||||||
uint8_t got[40000];
|
uint8_t got[40000];
|
||||||
|
|
||||||
n = strtol(Cmd, NULL, 0);
|
int n = strtol(Cmd, NULL, 0);
|
||||||
if (n == 0) n = 6000;
|
if (n == 0)
|
||||||
if (n > sizeof(got)) n = sizeof(got);
|
n = 20000;
|
||||||
|
|
||||||
PrintAndLog("Reading %d samples\n", n);
|
if (n > sizeof(got))
|
||||||
|
n = sizeof(got);
|
||||||
|
|
||||||
|
PrintAndLog("Reading %d samples from device memory\n", n);
|
||||||
GetFromBigBuf(got,n,0);
|
GetFromBigBuf(got,n,0);
|
||||||
WaitForResponse(CMD_ACK,NULL);
|
WaitForResponse(CMD_ACK,NULL);
|
||||||
for (int j = 0; j < n; j++) {
|
for (int j = 0; j < n; j++) {
|
||||||
GraphBuffer[cnt++] = ((int)got[j]) - 128;
|
GraphBuffer[j] = ((int)got[j]) - 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLog("Done!\n");
|
|
||||||
GraphTraceLen = n;
|
GraphTraceLen = n;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1558,8 +1526,8 @@ static command_t CommandTable[] =
|
||||||
{"help", CmdHelp, 1, "This help"},
|
{"help", CmdHelp, 1, "This help"},
|
||||||
{"amp", CmdAmp, 1, "Amplify peaks"},
|
{"amp", CmdAmp, 1, "Amplify peaks"},
|
||||||
{"askdemod", Cmdaskdemod, 1, "<0 or 1> -- Attempt to demodulate simple ASK tags"},
|
{"askdemod", Cmdaskdemod, 1, "<0 or 1> -- Attempt to demodulate simple ASK tags"},
|
||||||
{"askmandemod", Cmdaskmandemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK/Manchester tags and output binary (args optional[clock will try Auto-detect])"},
|
{"askmandemod", Cmdaskmandemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate ASK/Manchester tags and output binary (args optional[clock will try Auto-detect])"},
|
||||||
{"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK tags and output binary (args optional[clock will try Auto-detect])"},
|
{"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate ASK tags and output binary (args optional[clock will try Auto-detect])"},
|
||||||
{"autocorr", CmdAutoCorr, 1, "<window length> -- Autocorrelation over window"},
|
{"autocorr", CmdAutoCorr, 1, "<window length> -- Autocorrelation over window"},
|
||||||
{"biphaserawdecode",CmdBiphaseDecodeRaw,1,"[offset] Biphase decode binary stream already in graph buffer (offset = bit to start decode from)"},
|
{"biphaserawdecode",CmdBiphaseDecodeRaw,1,"[offset] Biphase decode binary stream already in graph buffer (offset = bit to start decode from)"},
|
||||||
{"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"},
|
{"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"},
|
||||||
|
@ -1570,7 +1538,7 @@ static command_t CommandTable[] =
|
||||||
{"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"},
|
{"fskdemod", CmdFSKdemod, 1, "Demodulate graph window as a HID FSK"},
|
||||||
{"fskhiddemod", CmdFSKdemodHID, 1, "Demodulate graph window as a HID FSK using raw"},
|
{"fskhiddemod", CmdFSKdemodHID, 1, "Demodulate graph window as a HID FSK using raw"},
|
||||||
{"fskiodemod", CmdFSKdemodIO, 1, "Demodulate graph window as an IO Prox FSK using raw"},
|
{"fskiodemod", CmdFSKdemodIO, 1, "Demodulate graph window as an IO Prox FSK using raw"},
|
||||||
{"fskrawdemod", CmdFSKrawdemod, 1, "[clock rate] [invert] [rchigh] [rclow] Demodulate graph window from FSK to binary (clock = 50)(invert = 1 or 0)(rchigh = 10)(rclow=8)"},
|
{"fskrawdemod", CmdFSKrawdemod, 1, "[clock rate] [invert] [rchigh] [rclow] Demodulate graph window from FSK to binary (clock = 50)(invert = 1|0)(rchigh = 10)(rclow=8)"},
|
||||||
{"grid", CmdGrid, 1, "<x> <y> -- overlay grid on graph window, use zero value to turn off either"},
|
{"grid", CmdGrid, 1, "<x> <y> -- overlay grid on graph window, use zero value to turn off either"},
|
||||||
{"hexsamples", CmdHexsamples, 0, "<bytes> [<offset>] -- Dump big buffer as hex bytes"},
|
{"hexsamples", CmdHexsamples, 0, "<bytes> [<offset>] -- Dump big buffer as hex bytes"},
|
||||||
{"hide", CmdHide, 1, "Hide graph window"},
|
{"hide", CmdHide, 1, "Hide graph window"},
|
||||||
|
@ -1585,8 +1553,8 @@ static command_t CommandTable[] =
|
||||||
{"plot", CmdPlot, 1, "Show graph window (hit 'h' in window for keystroke help)"},
|
{"plot", CmdPlot, 1, "Show graph window (hit 'h' in window for keystroke help)"},
|
||||||
{"pskclean", CmdPskClean, 1, "Attempt to clean psk wave"},
|
{"pskclean", CmdPskClean, 1, "Attempt to clean psk wave"},
|
||||||
{"pskdetectclock",CmdDetectNRZpskClockRate, 1, "Detect ASK, PSK, or NRZ clock rate"},
|
{"pskdetectclock",CmdDetectNRZpskClockRate, 1, "Detect ASK, PSK, or NRZ clock rate"},
|
||||||
{"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate psk indala tags and output ID binary & hex (args optional[clock will try Auto-detect])"},
|
{"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk indala tags and output ID binary & hex (args optional[clock will try Auto-detect])"},
|
||||||
{"psknrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate psk or nrz tags and output binary (args optional[clock will try Auto-detect])"},
|
{"psknrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk or nrz tags and output binary (args optional[clock will try Auto-detect])"},
|
||||||
{"samples", CmdSamples, 0, "[512 - 40000] -- Get raw samples for graph window"},
|
{"samples", CmdSamples, 0, "[512 - 40000] -- Get raw samples for graph window"},
|
||||||
{"save", CmdSave, 1, "<filename> -- Save trace (from graph window)"},
|
{"save", CmdSave, 1, "<filename> -- Save trace (from graph window)"},
|
||||||
{"scale", CmdScale, 1, "<int> -- Set cursor display scale"},
|
{"scale", CmdScale, 1, "<int> -- Set cursor display scale"},
|
||||||
|
|
|
@ -166,7 +166,6 @@ size_t getFromGraphBuf(uint8_t *buff)
|
||||||
int GetClock(const char *str, int peak, int verbose)
|
int GetClock(const char *str, int peak, int verbose)
|
||||||
{
|
{
|
||||||
int clock;
|
int clock;
|
||||||
// int clock2;
|
|
||||||
sscanf(str, "%i", &clock);
|
sscanf(str, "%i", &clock);
|
||||||
if (!strcmp(str, ""))
|
if (!strcmp(str, ""))
|
||||||
clock = 0;
|
clock = 0;
|
||||||
|
@ -177,46 +176,18 @@ int GetClock(const char *str, int peak, int verbose)
|
||||||
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
||||||
size_t size = getFromGraphBuf(grph);
|
size_t size = getFromGraphBuf(grph);
|
||||||
clock = DetectASKClock(grph,size,0);
|
clock = DetectASKClock(grph,size,0);
|
||||||
//clock2 = DetectClock2(peak);
|
|
||||||
/* Only print this message if we're not looping something */
|
/* Only print this message if we're not looping something */
|
||||||
if (!verbose){
|
if (!verbose){
|
||||||
PrintAndLog("Auto-detected clock rate: %d", clock);
|
PrintAndLog("Auto-detected clock rate: %d", clock);
|
||||||
//PrintAndLog("clock2: %d",clock2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
int GetNRZpskClock(const char *str, int peak, int verbose)
|
|
||||||
{
|
|
||||||
// return GetClock(str,peak,verbose);
|
|
||||||
int clock;
|
|
||||||
// int clock2;
|
|
||||||
sscanf(str, "%i", &clock);
|
|
||||||
if (!strcmp(str, ""))
|
|
||||||
clock = 0;
|
|
||||||
|
|
||||||
/* Auto-detect clock */
|
|
||||||
if (!clock)
|
|
||||||
{
|
|
||||||
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
|
||||||
size_t size = getFromGraphBuf(grph);
|
|
||||||
clock = DetectpskNRZClock(grph,size,0);
|
|
||||||
//clock2 = DetectClock2(peak);
|
|
||||||
/* Only print this message if we're not looping something */
|
|
||||||
if (!verbose){
|
|
||||||
PrintAndLog("Auto-detected clock rate: %d", clock);
|
|
||||||
//PrintAndLog("clock2: %d",clock2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return clock;
|
|
||||||
}
|
|
||||||
// Get or auto-detect clock rate
|
|
||||||
/*
|
|
||||||
int GetNRZpskClock(const char *str, int peak, int verbose)
|
int GetNRZpskClock(const char *str, int peak, int verbose)
|
||||||
{
|
{
|
||||||
int clock;
|
int clock;
|
||||||
// int clock2;
|
|
||||||
sscanf(str, "%i", &clock);
|
sscanf(str, "%i", &clock);
|
||||||
if (!strcmp(str, ""))
|
if (!strcmp(str, ""))
|
||||||
clock = 0;
|
clock = 0;
|
||||||
|
@ -225,15 +196,12 @@ int GetNRZpskClock(const char *str, int peak, int verbose)
|
||||||
if (!clock)
|
if (!clock)
|
||||||
{
|
{
|
||||||
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
||||||
int size = getFromGraphBuf(grph);
|
size_t size = getFromGraphBuf(grph);
|
||||||
clock = DetectASKClock(grph,size,0);
|
clock = DetectpskNRZClock(grph,size,0);
|
||||||
//clock2 = DetectClock2(peak);
|
|
||||||
// Only print this message if we're not looping something
|
// Only print this message if we're not looping something
|
||||||
if (!verbose){
|
if (!verbose){
|
||||||
PrintAndLog("Auto-detected clock rate: %d", clock);
|
PrintAndLog("Auto-detected clock rate: %d", clock);
|
||||||
//PrintAndLog("clock2: %d",clock2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue