* Updates the Graph trace with 0/1 values
*
* Arguments:
- * c : 0 or 1
+ * c : 0 or 1 (or invert)
*/
- //this method is dependant on all highs and lows to be the same(or clipped) this creates issues[marshmellow] it also ignores the clock
+ //this method ignores the clock
+
+ //this function strictly converts highs and lows to 1s and 0s for each sample in the graphbuffer
int Cmdaskdemod(const char *Cmd)
{
int i;
int c, high = 0, low = 0;
- // TODO: complain if we do not give 2 arguments here !
- // (AL - this doesn't make sense! we're only using one argument!!!)
sscanf(Cmd, "%i", &c);
- /* Detect high and lows and clock */
- // (AL - clock???)
+ /* Detect high and lows */
for (i = 0; i < GraphTraceLen; ++i)
{
if (GraphBuffer[i] > high)
* down)
*/
//[marhsmellow] change == to >= for high and <= for low for fuzz
- if ((GraphBuffer[i] == high) && (GraphBuffer[i - 1] == c)) {
+ if ((GraphBuffer[i] >= high) && (GraphBuffer[i - 1] == c)) {
GraphBuffer[i] = 1 - c;
- } else if ((GraphBuffer[i] == low) && (GraphBuffer[i - 1] == (1 - c))){
+ } else if ((GraphBuffer[i] <= low) && (GraphBuffer[i - 1] == (1 - c))){
GraphBuffer[i] = c;
} else {
/* No transition */
return 0;
}
+//this function strictly converts >1 to 1 and <1 to 0 for each sample in the graphbuffer
+int CmdGetBitStream(const char *Cmd)
+{
+ int i;
+ CmdHpf(Cmd);
+ for (i = 0; i < GraphTraceLen; i++) {
+ if (GraphBuffer[i] >= 1) {
+ GraphBuffer[i] = 1;
+ } else {
+ GraphBuffer[i] = 0;
+ }
+ }
+ RepaintGraphWindow();
+ return 0;
+}
+
+
//by marshmellow
void printBitStream(uint8_t BitStream[], uint32_t bitLen)
{
PrintAndLog("Biphase Decoded using offset: %d - # errors:%d - data:",offset,errCnt);
printBitStream(BitStream, size);
PrintAndLog("\nif bitstream does not look right try offset=1");
+ if (offset == 1) setDemodBuf(DemodBuffer,DemodBufferLen-1,1); //remove first bit from raw demod
return 1;
}
return;
}
for (size_t idx=0; idx<size; idx++){
- if(BitStream[idx]){
+ if(!BitStream[idx]){
rawStream[i++] = curPhase;
rawStream[i++] = curPhase;
curPhase ^= 1;
PrintAndLog(" <invert>, 1 for invert output");
PrintAndLog(" [set maximum allowed errors], default = 100.");
PrintAndLog("");
- PrintAndLog(" sample: data nrzrawdemod = demod a nrz/direct tag from GraphBuffer");
- PrintAndLog(" : data nrzrawdemod 32 = demod a nrz/direct tag from GraphBuffer using a clock of RF/32");
- PrintAndLog(" : data nrzrawdemod 32 1 = demod a nrz/direct tag from GraphBuffer using a clock of RF/32 and inverting data");
- PrintAndLog(" : data nrzrawdemod 1 = demod a nrz/direct tag from GraphBuffer while inverting data");
- PrintAndLog(" : data nrzrawdemod 64 1 0 = demod a nrz/direct tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
+ PrintAndLog(" sample: data rawdemod nr = demod a nrz/direct tag from GraphBuffer");
+ PrintAndLog(" : data rawdemod nr 32 = demod a nrz/direct tag from GraphBuffer using a clock of RF/32");
+ PrintAndLog(" : data rawdemod nr 32 1 = demod a nrz/direct tag from GraphBuffer using a clock of RF/32 and inverting data");
+ PrintAndLog(" : data rawdemod nr 1 = demod a nrz/direct tag from GraphBuffer while inverting data");
+ PrintAndLog(" : data rawdemod nr 64 1 0 = demod a nrz/direct tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
return 0;
}
return NRZrawDemod(Cmd, TRUE);
PrintAndLog(" <invert>, 1 for invert output");
PrintAndLog(" [set maximum allowed errors], default = 100.");
PrintAndLog("");
- PrintAndLog(" sample: data psk1rawdemod = demod a psk1 tag from GraphBuffer");
- PrintAndLog(" : data psk1rawdemod 32 = demod a psk1 tag from GraphBuffer using a clock of RF/32");
- PrintAndLog(" : data psk1rawdemod 32 1 = demod a psk1 tag from GraphBuffer using a clock of RF/32 and inverting data");
- PrintAndLog(" : data psk1rawdemod 1 = demod a psk1 tag from GraphBuffer while inverting data");
- PrintAndLog(" : data psk1rawdemod 64 1 0 = demod a psk1 tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
+ PrintAndLog(" sample: data rawdemod p1 = demod a psk1 tag from GraphBuffer");
+ PrintAndLog(" : data rawdemod p1 32 = demod a psk1 tag from GraphBuffer using a clock of RF/32");
+ PrintAndLog(" : data rawdemod p1 32 1 = demod a psk1 tag from GraphBuffer using a clock of RF/32 and inverting data");
+ PrintAndLog(" : data rawdemod p1 1 = demod a psk1 tag from GraphBuffer while inverting data");
+ PrintAndLog(" : data rawdemod p1 64 1 0 = demod a psk1 tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors");
return 0;
}
errCnt = PSKDemod(Cmd, TRUE);
PrintAndLog(" <invert>, 1 for invert output");
PrintAndLog(" [set maximum allowed errors], default = 100.");
PrintAndLog("");
- PrintAndLog(" sample: data psk2rawdemod = demod a psk2 tag from GraphBuffer, autodetect clock");
- PrintAndLog(" : data psk2rawdemod 32 = demod a psk2 tag from GraphBuffer using a clock of RF/32");
- PrintAndLog(" : data psk2rawdemod 32 1 = demod a psk2 tag from GraphBuffer using a clock of RF/32 and inverting output");
- PrintAndLog(" : data psk2rawdemod 1 = demod a psk2 tag from GraphBuffer, autodetect clock and invert output");
- PrintAndLog(" : data psk2rawdemod 64 1 0 = demod a psk2 tag from GraphBuffer using a clock of RF/64, inverting output and allowing 0 demod errors");
+ PrintAndLog(" sample: data rawdemod p2 = demod a psk2 tag from GraphBuffer, autodetect clock");
+ PrintAndLog(" : data rawdemod p2 32 = demod a psk2 tag from GraphBuffer using a clock of RF/32");
+ PrintAndLog(" : data rawdemod p2 32 1 = demod a psk2 tag from GraphBuffer using a clock of RF/32 and inverting output");
+ PrintAndLog(" : data rawdemod p2 1 = demod a psk2 tag from GraphBuffer, autodetect clock and invert output");
+ PrintAndLog(" : data rawdemod p2 64 1 0 = demod a psk2 tag from GraphBuffer using a clock of RF/64, inverting output and allowing 0 demod errors");
return 0;
}
errCnt=PSKDemod(Cmd, TRUE);
return 0;
}
+//zero mean GraphBuffer
int CmdHpf(const char *Cmd)
{
int i;
{"fskpyramiddemod",CmdFSKdemodPyramid,1, "Demodulate a Pyramid FSK tag from GraphBuffer"},
{"fskparadoxdemod",CmdFSKdemodParadox,1, "Demodulate a Paradox FSK tag from GraphBuffer"},
//{"fskrawdemod", CmdFSKrawdemod, 1, "[clock rate] [invert] [rchigh] [rclow] Demodulate graph window from FSK to bin (clock = 50)(invert = 1|0)(rchigh = 10)(rclow=8)"},
+ {"getbitstream", CmdGetBitStream, 1, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"},
{"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"},
{"hide", CmdHide, 1, "Hide graph window"},