1 bug fix + code trimming

This commit is contained in:
marshmellow42 2015-03-07 23:31:23 -05:00
parent df51693f95
commit 712ebfa6df
4 changed files with 58 additions and 144 deletions

View file

@ -461,7 +461,7 @@ static void fc(int c, int *n)
dest[((*n)++)]=0; dest[((*n)++)]=0;
} }
// an fc/8 encoded bit is a bit pattern of 11000000 x6 = 48 samples // an fc/8 encoded bit is a bit pattern of 11110000 x6 = 48 samples
if(c==8) { if(c==8) {
for (idx=0; idx<6; idx++) { for (idx=0; idx<6; idx++) {
dest[((*n)++)]=1; dest[((*n)++)]=1;
@ -475,7 +475,7 @@ static void fc(int c, int *n)
} }
} }
// an fc/10 encoded bit is a bit pattern of 1110000000 x5 = 50 samples // an fc/10 encoded bit is a bit pattern of 1111100000 x5 = 50 samples
if(c==10) { if(c==10) {
for (idx=0; idx<5; idx++) { for (idx=0; idx<5; idx++) {
dest[((*n)++)]=1; dest[((*n)++)]=1;
@ -492,52 +492,33 @@ static void fc(int c, int *n)
} }
} }
// compose fc/X fc/Y waveform (FSKx) // compose fc/X fc/Y waveform (FSKx)
static void fcAll(uint8_t c, int *n, uint8_t clock, uint16_t *modCnt) static void fcAll(uint8_t fc, int *n, uint8_t clock, uint16_t *modCnt)
{ {
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
uint8_t idx; uint8_t halfFC = fc/2;
uint8_t fcCnt; uint8_t wavesPerClock = clock/fc;
// c = count of field clock for this bit uint8_t mod = clock % fc; //modifier
uint8_t mod = clock % c; uint8_t modAdj = fc/mod; //how often to apply modifier
uint8_t modAdj = c/mod; bool modAdjOk = !(fc % mod); //if (fc % mod==0) modAdjOk=TRUE;
bool modAdjOk=FALSE;
if (c % mod==0) modAdjOk=TRUE;
// loop through clock - step field clock // loop through clock - step field clock
for (idx=0; idx < (uint8_t) clock/c; idx++){ for (uint8_t idx=0; idx < wavesPerClock; idx++){
// loop through field clock length - put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave) // put 1/2 FC length 1's and 1/2 0's per field clock wave (to create the wave)
for (fcCnt=0; fcCnt < c; fcCnt++){ //fudge slow transition from low to high - shorten wave by 1 memset(dest+(*n), 0, fc-halfFC); //in case of odd number use extra here
if (fcCnt < c/2){ memset(dest+(*n)+(fc-halfFC), 1, halfFC);
dest[((*n)++)]=0; *n += fc;
} else {
//fudge low to high transition
//if (idx==clock/c && dest[*n-1]==1 && mod>0) dest[((*n++))]=0;
//if (c==8 && fcCnt==5) continue;
dest[((*n)++)]=1;
}
}
} }
if (mod>0) (*modCnt)++; if (mod>0) (*modCnt)++;
if ((mod>0) && modAdjOk){ //fsk2 if ((mod>0) && modAdjOk){ //fsk2
if ((*modCnt % modAdj) == 0){ //if 4th 8 length wave in a rf/50 add extra 8 length wave if ((*modCnt % modAdj) == 0){ //if 4th 8 length wave in a rf/50 add extra 8 length wave
for (fcCnt=0; fcCnt < c; fcCnt++){ //fudge slow transition from low to high - shorten wave by 1 memset(dest+(*n), 0, fc-halfFC);
if (fcCnt < c/2){ memset(dest+(*n)+(fc-halfFC), 1, halfFC);
dest[((*n)++)]=0; *n += fc;
} else {
//if (c==8 && fcCnt==5) continue;
dest[((*n)++)]=1;
} }
} }
}
}
//Dbprintf("mod: %d, modAdj %d, modc %d",mod, modAdj, c % mod);
if (mod>0 && !modAdjOk){ //fsk1 if (mod>0 && !modAdjOk){ //fsk1
for (idx=0; idx < mod; idx++){ memset(dest+(*n), 0, mod-(mod/2));
if (idx < mod/2) { memset(dest+(*n)+(mod-(mod/2)), 1, mod/2);
dest[((*n)++)]=0; *n += mod;
} else {
dest[((*n)++)]=1;
}
}
} }
} }
@ -607,12 +588,9 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
uint8_t fcHigh = arg1 >> 8; uint8_t fcHigh = arg1 >> 8;
uint8_t fcLow = arg1 & 0xFF; uint8_t fcLow = arg1 & 0xFF;
uint16_t modCnt = 0; uint16_t modCnt = 0;
//spacer bit
uint8_t clk = arg2 & 0xFF; uint8_t clk = arg2 & 0xFF;
uint8_t invert = (arg2 >> 8) & 1; uint8_t invert = (arg2 >> 8) & 1;
//fcAll(0, &n, clk);
WDT_HIT();
for (i=0; i<size; i++){ for (i=0; i<size; i++){
if (BitStream[i] == invert){ if (BitStream[i] == invert){
fcAll(fcLow, &n, clk, &modCnt); fcAll(fcLow, &n, clk, &modCnt);
@ -621,42 +599,16 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
} }
} }
Dbprintf("Simulating with fcHigh: %d, fcLow: %d, clk: %d, invert: %d, n: %d",fcHigh, fcLow, clk, invert, n); Dbprintf("Simulating with fcHigh: %d, fcLow: %d, clk: %d, invert: %d, n: %d",fcHigh, fcLow, clk, invert, n);
WDT_HIT(); /*Dbprintf("DEBUG: First 32:");
/*Dbprintf("First 64:");
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
i=0; i=0;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]); Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16; i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]); Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
*/ */
if (ledcontrol) if (ledcontrol)
LED_A_ON(); LED_A_ON();
SimulateTagLowFrequency(n, 0, ledcontrol); SimulateTagLowFrequency(n, 0, ledcontrol);
if (ledcontrol) if (ledcontrol)
@ -667,28 +619,15 @@ void CmdFSKsimTAG(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
static void askSimBit(uint8_t c, int *n, uint8_t clock, uint8_t manchester) static void askSimBit(uint8_t c, int *n, uint8_t clock, uint8_t manchester)
{ {
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
uint8_t idx; uint8_t halfClk = clock/2;
// c = current bit 1 or 0 // c = current bit 1 or 0
int i = 0;
// for when we want a separator
if (c==2) { //separator
for (i=0; i<clock/2; i++){
dest[((*n)++)]=0;
}
} else {
if (manchester){ if (manchester){
for (idx=0; idx < (uint8_t) clock/2; idx++){ memset(dest+(*n), c, halfClk);
dest[((*n)++)]=c; memset(dest+(*n) + halfClk, c^1, halfClk);
}
for (idx=0; idx < (uint8_t) clock/2; idx++){
dest[((*n)++)]=c^1;
}
} else { } else {
for (idx=0; idx < (uint8_t) clock; idx++){ memset(dest+(*n), c, clock);
dest[((*n)++)]=c;
}
}
} }
*n += clock;
} }
// args clock, ask/man or askraw, invert, transmission separator // args clock, ask/man or askraw, invert, transmission separator
@ -703,24 +642,20 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
for (i=0; i<size; i++){ for (i=0; i<size; i++){
askSimBit(BitStream[i]^invert, &n, clk, manchester); askSimBit(BitStream[i]^invert, &n, clk, manchester);
} }
if (separator==1) Dbprintf("sorry but separator option not yet available"); //askSimBit(2, &n, clk, manchester); if (separator==1) Dbprintf("sorry but separator option not yet available");
Dbprintf("Simulating with clk: %d, invert: %d, manchester: %d, separator: %d, n: %d",clk, invert, manchester, separator, n); Dbprintf("Simulating with clk: %d, invert: %d, manchester: %d, separator: %d, n: %d",clk, invert, manchester, separator, n);
//DEBUG //DEBUG
//Dbprintf("First 64:"); //Dbprintf("First 32:");
//uint8_t *dest = BigBuf_get_addr(); //uint8_t *dest = BigBuf_get_addr();
//i=0; //i=0;
//Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]); //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
//i+=16; //i+=16;
//Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]); //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
//i+=16;
//Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
//i+=16;
//Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
if (ledcontrol) if (ledcontrol)
LED_A_ON(); LED_A_ON();
SimulateTagLowFrequency(n, 0, ledcontrol); SimulateTagLowFrequency(n, 0, ledcontrol);
if (ledcontrol) if (ledcontrol)
@ -731,27 +666,22 @@ void CmdASKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
static void pskSimBit(uint8_t waveLen, int *n, uint8_t clk, uint8_t *curPhase, bool phaseChg) static void pskSimBit(uint8_t waveLen, int *n, uint8_t clk, uint8_t *curPhase, bool phaseChg)
{ {
uint8_t *dest = BigBuf_get_addr(); uint8_t *dest = BigBuf_get_addr();
uint8_t idx; uint8_t halfWave = waveLen/2;
//uint8_t idx;
int i = 0; int i = 0;
if (phaseChg){ if (phaseChg){
// write phase change // write phase change
for (idx=0; idx < waveLen/2; idx++){ memset(dest+(*n), *curPhase^1, halfWave);
dest[((*n)++)] = *curPhase^1; memset(dest+(*n) + halfWave, *curPhase, halfWave);
} *n += waveLen;
for (idx=0; idx < waveLen/2; idx++){
dest[((*n)++)] = *curPhase;
}
*curPhase ^= 1; *curPhase ^= 1;
i+=waveLen; i += waveLen;
} }
//write each normal clock wave for the clock duration //write each normal clock wave for the clock duration
for (; i < clk; i+=waveLen){ for (; i < clk; i+=waveLen){
for (idx=0; idx<waveLen/2; idx++){ memset(dest+(*n), *curPhase, halfWave);
dest[((*n)++)] = *curPhase; memset(dest+(*n) + halfWave, *curPhase^1, halfWave);
} *n += waveLen;
for (idx=0; idx<waveLen/2; idx++){
dest[((*n)++)] = *curPhase^1;
}
} }
} }
@ -763,9 +693,6 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
uint8_t clk = arg1 >> 8; uint8_t clk = arg1 >> 8;
uint8_t carrier = arg1 & 0xFF; uint8_t carrier = arg1 & 0xFF;
uint8_t invert = arg2 & 0xFF; uint8_t invert = arg2 & 0xFF;
//uint8_t phase = carrier/2; //extra phase changing bits = 1/2 a carrier wave to change the phase
//uint8_t invert = (arg2 >> 8) & 1;
WDT_HIT();
uint8_t curPhase = 0; uint8_t curPhase = 0;
for (i=0; i<size; i++){ for (i=0; i<size; i++){
if (BitStream[i] == curPhase){ if (BitStream[i] == curPhase){
@ -775,25 +702,12 @@ void CmdPSKsimTag(uint16_t arg1, uint16_t arg2, size_t size, uint8_t *BitStream)
} }
} }
Dbprintf("Simulating with Carrier: %d, clk: %d, invert: %d, n: %d",carrier, clk, invert, n); Dbprintf("Simulating with Carrier: %d, clk: %d, invert: %d, n: %d",carrier, clk, invert, n);
WDT_HIT(); //Dbprintf("DEBUG: First 32:");
Dbprintf("First 128:"); //uint8_t *dest = BigBuf_get_addr();
uint8_t *dest = BigBuf_get_addr(); //i=0;
i=0; //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]); //i+=16;
i+=16; //Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
i+=16;
Dbprintf("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", dest[i],dest[i+1],dest[i+2],dest[i+3],dest[i+4],dest[i+5],dest[i+6],dest[i+7],dest[i+8],dest[i+9],dest[i+10],dest[i+11],dest[i+12],dest[i+13],dest[i+14],dest[i+15]);
if (ledcontrol) if (ledcontrol)
LED_A_ON(); LED_A_ON();

View file

@ -15,6 +15,7 @@ command_t * CmdDataCommands();
int CmdData(const char *Cmd); int CmdData(const char *Cmd);
void printDemodBuff(void); void printDemodBuff(void);
void printBitStream(uint8_t BitStream[], uint32_t bitLen);
void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx); void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx);
int CmdAmp(const char *Cmd); int CmdAmp(const char *Cmd);
int Cmdaskdemod(const char *Cmd); int Cmdaskdemod(const char *Cmd);

View file

@ -597,6 +597,7 @@ int usage_lf_simpsk(void)
PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer"); PrintAndLog(" d <hexdata> Data to sim as hex - omit to sim from DemodBuffer");
return 0; return 0;
} }
// by marshmellow - sim ask data given clock, fcHigh, fcLow, invert // by marshmellow - sim ask data given clock, fcHigh, fcLow, invert
// - allow pull data from DemodBuffer // - allow pull data from DemodBuffer
int CmdLFfskSim(const char *Cmd) int CmdLFfskSim(const char *Cmd)

View file

@ -1094,11 +1094,9 @@ void psk1TOpsk2(uint8_t *BitStream, size_t size)
// from only transition waves are 1s to phase shifts change bit // from only transition waves are 1s to phase shifts change bit
void psk2TOpsk1(uint8_t *BitStream, size_t size) void psk2TOpsk1(uint8_t *BitStream, size_t size)
{ {
size_t i; uint8_t phase=0;
uint8_t phase=BitStream[0]; for (size_t i=0; i<size; i++){
//uint8_t lastBit=BitStream[0]; if (BitStream[i]==1){
for (i=1; i<size; i++){
if (phase!=BitStream[i]){
phase ^=1; phase ^=1;
} }
BitStream[i]=phase; BitStream[i]=phase;