return 1;
}
-//by marshmellow (based on existing demod + holiman's refactor)
-//Paradox Prox demod - FSK RF/50 with preamble of 00011101 (then manchester encoded)
+//by marshmellow
+//Paradox Prox demod - FSK RF/50 with preamble of 00001111 (then manchester encoded)
//print full Paradox Prox ID and some bit format details if found
int CmdFSKdemodParadox(const char *Cmd)
{
return 0;
}
-int PSKnrzDemod(const char *Cmd)
+int PSKnrzDemod(const char *Cmd, uint8_t verbose)
{
int invert=0;
int clk=0;
if (g_debugMode==1) PrintAndLog("no data found, clk: %d, invert: %d, numbits: %d, errCnt: %d",clk,invert,BitLen,errCnt);
return -1;
}
- PrintAndLog("Tried PSK/NRZ Demod using Clock: %d - invert: %d - Bits Found: %d",clk,invert,BitLen);
+ if (verbose) PrintAndLog("Tried PSK/NRZ Demod using Clock: %d - invert: %d - Bits Found: %d",clk,invert,BitLen);
//prime demod buffer for output
setDemodBuf(BitStream,BitLen,0);
{
int ans;
if (strlen(Cmd)>0){
- ans = PSKnrzDemod(Cmd);
+ ans = PSKnrzDemod(Cmd, 0);
} else{ //default to RF/32
- ans = PSKnrzDemod("32");
+ ans = PSKnrzDemod("32", 0);
}
if (ans < 0){
return 0;
}
-//by marshmellow
-//takes 2 arguments - clock and invert both as integers
-//attempts to demodulate ask only
-//prints binary found and saves in graphbuffer for further commands
+// by marshmellow
+// takes 2 arguments - clock and invert both as integers
+// attempts to demodulate psk only
+// prints binary found and saves in demodbuffer for further commands
int CmdpskNRZrawDemod(const char *Cmd)
{
int errCnt;
- errCnt = PSKnrzDemod(Cmd);
+ errCnt = PSKnrzDemod(Cmd, 1);
//output
if (errCnt<0){
if (g_debugMode) PrintAndLog("Error demoding: %d",errCnt);
return 0;
}
+// by marshmellow
+// takes same args as cmdpsknrzrawdemod
+int CmdPSK2rawDemod(const char *Cmd)
+{
+ int errCnt=0;
+ errCnt=PSKnrzDemod(Cmd, 1);
+ if (errCnt<0){
+ if (g_debugMode) PrintAndLog("Error demoding: %d",errCnt);
+ return 0;
+ }
+ psk1TOpsk2(DemodBuffer, DemodBufferLen);
+ if (errCnt>0){
+ if (g_debugMode){
+ PrintAndLog("# Errors during Demoding (shown as 77 in bit stream): %d",errCnt);
+ PrintAndLog("PSK2 demoded bitstream:");
+ // Now output the bitstream to the scrollback by line of 16 bits
+ printDemodBuff();
+ }
+ }else{
+ PrintAndLog("PSK2 demoded bitstream:");
+ // Now output the bitstream to the scrollback by line of 16 bits
+ printDemodBuff();
+ }
+ return 1;
+}
+
int CmdGrid(const char *Cmd)
{
sscanf(Cmd, "%i %i", &PlotGridX, &PlotGridY);
{"plot", CmdPlot, 1, "Show graph window (hit 'h' in window for keystroke help)"},
{"pskclean", CmdPskClean, 1, "Attempt to clean psk wave"},
{"pskdetectclock",CmdDetectNRZpskClockRate, 1, "Detect ASK, PSK, or NRZ clock rate"},
- {"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk indala tags and output ID binary & hex (args optional)"},
- {"psknrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk or nrz tags and output binary (args optional)"},
+ {"pskindalademod",CmdIndalaDecode, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk1 indala tags and output ID binary & hex (args optional)"},
+ {"psk1nrzrawdemod",CmdpskNRZrawDemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk1 or nrz tags and output binary (args optional)"},
+ {"psk2rawdemod", CmdPSK2rawDemod, 1, "[clock] [invert<0|1>] -- Attempt to demodulate psk2 tags and output binary (args optional)"},
{"samples", CmdSamples, 0, "[512 - 40000] -- Get raw samples for graph window"},
{"save", CmdSave, 1, "<filename> -- Save trace (from graph window)"},
{"scale", CmdScale, 1, "<int> -- Set cursor display scale"},
return -4;
}
-
// by marshmellow
// not perfect especially with lower clocks or VERY good antennas (heavy wave clipping)
// maybe somehow adjust peak trimming value based on samples to fix?
return clk[best];
}
-
//by marshmellow
//detect psk clock by reading #peaks vs no peaks(or errors)
int DetectpskNRZClock(uint8_t dest[], size_t size, int clock)
return clk[best];
}
-//by marshmellow (attempt to get rid of high immediately after a low)
+// by marshmellow (attempt to get rid of high immediately after a low)
void pskCleanWave(uint8_t *BitStream, size_t size)
{
int i;
return;
}
+// by marshmellow
+// convert psk1 demod to psk2 demod
+// only transition waves are 1s
+void psk1TOpsk2(uint8_t *BitStream, size_t size)
+{
+ size_t i=1;
+ uint8_t lastBit=BitStream[0];
+ for (; i<size; i++){
+ if (lastBit!=BitStream[i]){
+ lastBit=BitStream[i];
+ BitStream[i]=1;
+ } else {
+ BitStream[i]=0;
+ }
+ }
+ return;
+}
-//redesigned by marshmellow adjusted from existing decode functions
-//indala id decoding - only tested on 26 bit tags, but attempted to make it work for more
+// redesigned by marshmellow adjusted from existing decode functions
+// indala id decoding - only tested on 26 bit tags, but attempted to make it work for more
int indala26decode(uint8_t *bitStream, size_t *size, uint8_t *invert)
{
//26 bit 40134 format (don't know other formats)
return 1;
}
-
-//by marshmellow - demodulate PSK1 wave or NRZ wave (both similar enough)
-//peaks switch bit (high=1 low=0) each clock cycle = 1 bit determined by last peak
+// by marshmellow - demodulate PSK1 wave or NRZ wave (both similar enough)
+// peaks invert bit (high=1 low=0) each clock cycle = 1 bit determined by last peak
int pskNRZrawDemod(uint8_t *dest, size_t *size, int *clk, int *invert)
{
pskCleanWave(dest,*size);
uint32_t bestStart = *size;
uint32_t maxErr = (*size/1000);
uint32_t bestErrCnt = maxErr;
- //uint8_t midBit=0;
uint8_t curBit=0;
uint8_t bitHigh=0;
uint8_t ignorewin=*clk/8;
return errCnt;
}
-
//by marshmellow
//detects the bit clock for FSK given the high and low Field Clocks
uint8_t detectFSKClk(uint8_t *BitStream, size_t size, uint8_t fcHigh, uint8_t fcLow)