//prints binary found and saves in graphbuffer for further commands
int Cmdaskrawdemod(const char *Cmd)
{
- uint32_t i;
+
int invert=0;
int clk=0;
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
}
int BitLen = getFromGraphBuf(BitStream);
int errCnt=0;
- errCnt = askrawdemod(BitStream, &BitLen,&clk,&invert);
+ errCnt = askrawdemod(BitStream, &BitLen, &clk, &invert);
if (errCnt==-1){ //throw away static - allow 1 and -1 (in case of threshold command first)
PrintAndLog("no data found");
return 0;
PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d",clk,invert,BitLen);
//PrintAndLog("Data start pos:%d, lastBit:%d, stop pos:%d, numBits:%d",iii,lastBit,i,bitnum);
//move BitStream back to GraphBuffer
-
- ClearGraph(0);
- for (i=0; i < BitLen; ++i){
- GraphBuffer[i]=BitStream[i];
- }
- GraphTraceLen=BitLen;
- RepaintGraphWindow();
-
- //output
+ setGraphBuf(BitStream, BitLen);
+
if (errCnt>0){
PrintAndLog("# Errors during Demoding (shown as 77 in bit stream): %d",errCnt);
}
+
PrintAndLog("ASK demoded bitstream:");
+
// Now output the bitstream to the scrollback by line of 16 bits
printBitStream(BitStream,BitLen);
bit ^= 1;
AppendGraph(0, clock, bit);
- // for (j = 0; j < (int)(clock/2); j++)
- // GraphBuffer[(i * clock) + j] = bit ^ 1;
- // for (j = (int)(clock/2); j < clock; j++)
- // GraphBuffer[(i * clock) + j] = bit;
}
RepaintGraphWindow();
int CmdDetectClockRate(const char *Cmd)
{
GetClock("",0,0);
- //int clock = DetectASKClock(0);
- //PrintAndLog("Auto-detected clock rate: %d", clock);
return 0;
}
PrintAndLog("actual data bits start at sample %d", maxPos);
PrintAndLog("length %d/%d", highLen, lowLen);
- uint8_t bits[46];
- bits[sizeof(bits)-1] = '\0';
+ uint8_t bits[46] = {0x00};
// find bit pairs and manchester decode them
for (i = 0; i < arraylen(bits) - 1; ++i) {
int CmdSamples(const char *Cmd)
{
- int cnt = 0;
- int n;
- uint8_t got[40000];
-
- n = strtol(Cmd, NULL, 0);
- if (n == 0) n = 6000;
- if (n > sizeof(got)) n = sizeof(got);
+ uint8_t got[40000] = {0x00};
+
+ int n = strtol(Cmd, NULL, 0);
+ if (n == 0)
+ n = 20000;
+
+ if (n > sizeof(got))
+ n = sizeof(got);
- PrintAndLog("Reading %d samples\n", n);
+ PrintAndLog("Reading %d samples from device memory\n", n);
GetFromBigBuf(got,n,0);
WaitForResponse(CMD_ACK,NULL);
- for (int j = 0; j < n; j++) {
- GraphBuffer[cnt++] = ((int)got[j]) - 128;
+ for (int j = 0; j < n; ++j) {
+ GraphBuffer[j] = ((int)got[j]) - 128;
}
-
- PrintAndLog("Done!\n");
GraphTraceLen = n;
RepaintGraphWindow();
return 0;
int CmdTuneSamples(const char *Cmd)
{
- int cnt = 0;
- int n = 255;
- uint8_t got[255];
-
- PrintAndLog("Reading %d samples\n", n);
- GetFromBigBuf(got,n,7256); // armsrc/apps.h: #define FREE_BUFFER_OFFSET 7256
- WaitForResponse(CMD_ACK,NULL);
- for (int j = 0; j < n; j++) {
- GraphBuffer[cnt++] = ((int)got[j]) - 128;
+ int timeout = 0;
+ printf("\nMeasuring antenna characteristics, please wait...");
+
+ UsbCommand c = {CMD_MEASURE_ANTENNA_TUNING};
+ SendCommand(&c);
+
+ UsbCommand resp;
+ while(!WaitForResponseTimeout(CMD_MEASURED_ANTENNA_TUNING,&resp,1000)) {
+ timeout++;
+ printf(".");
+ if (timeout > 7) {
+ PrintAndLog("\nNo response from Proxmark. Aborting...");
+ return 1;
+ }
+ }
+
+ int peakv, peakf;
+ int vLf125, vLf134, vHf;
+ vLf125 = resp.arg[0] & 0xffff;
+ vLf134 = resp.arg[0] >> 16;
+ vHf = resp.arg[1] & 0xffff;;
+ peakf = resp.arg[2] & 0xffff;
+ peakv = resp.arg[2] >> 16;
+ PrintAndLog("");
+ PrintAndLog("# LF antenna: %5.2f V @ 125.00 kHz", vLf125/1000.0);
+ PrintAndLog("# LF antenna: %5.2f V @ 134.00 kHz", vLf134/1000.0);
+ PrintAndLog("# LF optimal: %5.2f V @%9.2f kHz", peakv/1000.0, 12000.0/(peakf+1));
+ PrintAndLog("# HF antenna: %5.2f V @ 13.56 MHz", vHf/1000.0);
+ if (peakv<2000)
+ PrintAndLog("# Your LF antenna is unusable.");
+ else if (peakv<10000)
+ PrintAndLog("# Your LF antenna is marginal.");
+ if (vHf<2000)
+ PrintAndLog("# Your HF antenna is unusable.");
+ else if (vHf<5000)
+ PrintAndLog("# Your HF antenna is marginal.");
+
+ for (int i = 0; i < 256; i++) {
+ GraphBuffer[i] = resp.d.asBytes[i] - 128;
}
PrintAndLog("Done! Divisor 89 is 134khz, 95 is 125khz.\n");
PrintAndLog("\n");
- GraphTraceLen = n;
- RepaintGraphWindow();
+ GraphTraceLen = 256;
+ ShowGraphWindow();
+
return 0;
}
{"help", CmdHelp, 1, "This help"},
{"amp", CmdAmp, 1, "Amplify peaks"},
{"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])"},
- {"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert<0 or 1>] -- Attempt to demodulate ASK 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"},
+ {"askrawdemod", Cmdaskrawdemod, 1, "[clock] [invert <0|1>] -- Attempt to demodulate ASK tags and output binary"},
{"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)"},
{"bitsamples", CmdBitsamples, 0, "Get raw samples as bitstring"},