Fix: removed a call to free, which I think made linux people unhappy during "lf t55xx rd 0"...
Add: "lf t55xx fsk" now kind of outputs binary from "FSK2a R/40 R/50"..
#include "string.h"
#include "../common/iso15693tools.h"
#include "../common/cmd.h"
+#include "crapto1.h"
+#include "mifareutil.h"
#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
//-----------------------------------------------------------------------------
void AcquireRawAdcSamplesIso15693(void)
{
+ uint8_t *dest = mifare_get_bigbufptr();
+
int c = 0;
- uint8_t *dest = (uint8_t *)BigBuf;
int getNext = 0;
-
int8_t prev = 0;
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
void RecordRawAdcSamplesIso15693(void)
{
+ uint8_t *dest = mifare_get_bigbufptr();
+
int c = 0;
- uint8_t *dest = (uint8_t *)BigBuf;
int getNext = 0;
-
int8_t prev = 0;
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
FpgaSetupSsc();
// Start from off (no field generated)
- FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
- SpinDelay(200);
+ FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
+ SpinDelay(200);
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
// split into two routines so we can avoid timing issues after sending commands //
void DoAcquisition125k(int trigger_threshold)
{
- uint8_t *dest = (uint8_t *)BigBuf;
- int n = sizeof(BigBuf);
+ uint8_t *dest = mifare_get_bigbufptr();
+ int n = 8000;
int i;
- memset(dest, 0, n);
+ memset(dest, 0x00, n);
i = 0;
for(;;) {
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
}
Dbprintf("buffer samples: %02x %02x %02x %02x %02x %02x %02x %02x ...",
dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
+
}
void ModThenAcquireRawAdcSamples125k(int delay_off, int period_0, int period_1, uint8_t *command)
void CmdIOdemodFSK(int findone, int *high, int *low, int ledcontrol)
{
- uint8_t *dest = (uint8_t *)BigBuf;
+ uint8_t *dest = mifare_get_bigbufptr();
int m=0, n=0, i=0, idx=0, lastval=0;
int found=0;
uint32_t code=0, code2=0;
- //uint32_t hi2=0, hi=0, lo=0;
-
- FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
- FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
- FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_ADC | FPGA_LF_ADC_READER_FIELD);
- // Connect the A/D to the peak-detected low-frequency path.
- SetAdcMuxFor(GPIO_MUXSEL_LOPKD);
-
- // Give it a bit of time for the resonant antenna to settle.
- SpinDelay(50);
-
- // Now set up the SSC to get the ADC samples that are now streaming at us.
- FpgaSetupSsc();
+ LFSetupFPGAForADC(0, true);
for(;;) {
WDT_HIT();
}
i = 0;
- m = sizeof(BigBuf);
+ m = 30000;
memset(dest,128,m);
for(;;) {
if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_TXRDY)) {
dest[i] = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
// we don't care about actual value, only if it's more or less than a
// threshold essentially we capture zero crossings for later analysis
- if(dest[i] < 127) dest[i] = 0; else dest[i] = 1;
- i++;
+ dest[i] = (dest[i] < 127) ? 0 : 1;
+ ++i;
if (ledcontrol)
LED_D_OFF();
- if(i >= m) {
+ if(i >= m)
break;
- }
}
}
for( i=0; idx<m; idx++) {
if (dest[idx-1]<dest[idx]) {
dest[i]=idx-lastval;
- if (dest[i] <= 8) {
- dest[i]=1;
- } else {
- dest[i]=0;
- }
-
+ dest[i] = (dest[i] <= 8) ? 1:0;
lastval=idx;
i++;
}
} else {
n=(n+1)/6; // fc/10 in sets of 6
}
- switch (n) { // stuff appropriate bits in buffer
- case 0:
- case 1: // one bit
- dest[i++]=dest[idx-1]^1;
- //Dbprintf("%d",dest[idx-1]);
- break;
- case 2: // two bits
- dest[i++]=dest[idx-1]^1;
- dest[i++]=dest[idx-1]^1;
- //Dbprintf("%d",dest[idx-1]);
- //Dbprintf("%d",dest[idx-1]);
- break;
- case 3: // 3 bit start of frame markers
- for(int j=0; j<3; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 4:
- for(int j=0; j<4; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 5:
- for(int j=0; j<5; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 6:
- for(int j=0; j<6; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 7:
- for(int j=0; j<7; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 8:
- for(int j=0; j<8; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 9:
- for(int j=0; j<9; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 10:
- for(int j=0; j<10; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 11:
- for(int j=0; j<11; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
- }
- break;
- case 12:
- for(int j=0; j<12; j++){
- dest[i++]=dest[idx-1]^1;
- // Dbprintf("%d",dest[idx-1]);
+
+ // stuff appropriate bits in buffer
+ if ( n==0 )
+ dest[i++]=dest[idx-1]^1;
+ else {
+ if ( n < 13){
+ for(int j=0; j<n; j++){
+ dest[i++]=dest[idx-1]^1;
}
- break;
- default: // this shouldn't happen, don't stuff any bits
- //Dbprintf("%d",dest[idx-1]);
- break;
+ }
}
+
n=0;
lastval=dest[idx];
}
}//end for
- /*for(int j=0; j<64;j+=8){
- Dbprintf("%d%d%d%d%d%d%d%d",dest[j],dest[j+1],dest[j+2],dest[j+3],dest[j+4],dest[j+5],dest[j+6],dest[j+7]);
- }
- Dbprintf("\n");*/
+
m=i;
WDT_HIT();
unknown <<=1;
if (dest[idx+j]) unknown |= 1;
}
- for(int j=36;j<45;j++){
+ for(int j=37;j<45;j++){
//Dbprintf("%d",dest[idx+j]);
number <<=1;
if (dest[idx+j]) number |= 1;
number <<=1;
if (dest[idx+j]) number |= 1;
}
+
for(int j=0; j<32; j++){
- code <<=1;
- if(dest[idx+j]) code |= 1;
+ code <<=1;
+ if(dest[idx+j]) code |= 1;
}
for(int j=32; j<64; j++){
- code2 <<=1;
- if(dest[idx+j]) code2 |= 1;
+ code2 <<=1;
+ if(dest[idx+j]) code2 |= 1;
}
Dbprintf("XSF(%02d)%02x:%d (%08x%08x)",version,unknown,number,code,code2);
}
// if we're only looking for one tag
if (findone){
- //*high = hi;
- //*low = lo;
LED_A_OFF();
return;
}
-
- //hi=0;
- //lo=0;
+
found=0;
}
-
}
}
WDT_HIT();
VPATH = ../common
OBJDIR = obj
-LDLIBS = -L/mingw/lib -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lreadline -lpthread -lcrypto -lgdi32
+LDLIBS = -L/mingw/lib -L/opt/local/lib -L/usr/local/lib ../liblua/liblua.a -lm -lreadline -lpthread -lcrypto -lgdi32
LDFLAGS = $(COMMON_FLAGS)
-CFLAGS = -std=c99 -I. -I../include -I../common -I/mingw/include -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4 $(ICE_FLAGS)
+CFLAGS = -std=c99 -I. -I../include -I../common -I/mingw/include -I/opt/local/include -I../liblua -Wall $(COMMON_FLAGS) -g -O4 $(ICE_FLAGS)
LUAPLATFORM = generic
ifneq (,$(findstring MINGW,$(platform)))
-CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets
+CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I$(QTDIR)/include/QtWidgets -I/mingw/include
QTLDLIBS = -L$(QTDIR)/lib -lQt5Core -lQt5Gui -lQt5Widgets
MOC = $(QTDIR)/bin/moc
LUAPLATFORM = mingw
#define Crc(data,datalen) Iso15693Crc(data,datalen)
#define AddCrc(data,datalen) Iso15693AddCrc(data,datalen)
#define sprintUID(target,uid) Iso15693sprintUID(target,uid)
+#define TRACE_BUFF_SIZE 12000
// structure and database for uid -> tagtype lookups
typedef struct {
{
UsbCommand c = {CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693};
SendCommand(&c);
+
+ uint8_t data[TRACE_BUFF_SIZE] = {0x00};
+
+ GetFromBigBuf(data,TRACE_BUFF_SIZE,3560); //3560 -- should be offset..
+ WaitForResponseTimeout(CMD_ACK,NULL, 1500);
+
+ for (int j = 0; j < TRACE_BUFF_SIZE; j++) {
+ GraphBuffer[j] = ((int)data[j]) ;
+ }
+ GraphTraceLen = TRACE_BUFF_SIZE;
+ RepaintGraphWindow();
return 0;
}
{
UsbCommand c = {CMD_RECORD_RAW_ADC_SAMPLES_ISO_15693};
SendCommand(&c);
+
+ uint8_t data[TRACE_BUFF_SIZE] = {0x00};
+
+ GetFromBigBuf(data,TRACE_BUFF_SIZE,3560); //3560 -- should be offset..
+ WaitForResponseTimeout(CMD_ACK,NULL, 1500);
+
+ for (int j = 0; j < TRACE_BUFF_SIZE; j++) {
+ GraphBuffer[j] = ((int)data[j]) ;
+ }
+ GraphTraceLen = TRACE_BUFF_SIZE;
+ RepaintGraphWindow();
return 0;
}
int CmdHF15CmdDebug( const char *cmd) {
int debug=atoi(cmd);
if (strlen(cmd)<1) {
- PrintAndLog("Usage: hf 15 cmd debug <0/1>");
- PrintAndLog(" 0..no debugging output 1..turn debugging on");
+ PrintAndLog("Usage: hf 15 cmd debug <0|1>");
+ PrintAndLog(" 0 no debugging");
+ PrintAndLog(" 1 turn debugging on");
return 0;
}
int size = GetCardSize(); \r
char cmdp = param_getchar(Cmd, 0);\r
\r
- PrintAndLog("Got %d",size);\r
- \r
- return 0;\r
\r
+\r
if ( size > -1) \r
- cmdp = (char)48+size;\r
- \r
+ cmdp = (char)(48+size);\r
+\r
+ PrintAndLog("Got %d",cmdp);\r
+ \r
switch (cmdp) {\r
case '0' : numSectors = 5; break;\r
case '1' : \r
}
SendCommand(&c);
WaitForResponse(CMD_ACK,NULL);
+
+ size_t BUFF_SIZE = 8000;
+ uint8_t data[BUFF_SIZE];
+
+ GetFromBigBuf(data,BUFF_SIZE,3560); //3560 -- should be offset..
+ WaitForResponseTimeout(CMD_ACK,NULL, 1500);
+
+ for (int j = 0; j < BUFF_SIZE; j++) {
+ GraphBuffer[j] = ((int)data[j]);
+ }
+ GraphTraceLen = BUFF_SIZE;
+
return 0;
}
{
{"help", CmdHelp, 1, "This help"},
{"cmdread", CmdLFCommandRead, 0, "<off period> <'0' period> <'1' period> <command> ['h'] -- Modulate LF reader field to send command before read (all periods in microseconds) (option 'h' for 134)"},
- {"em4x", CmdLFEM4X, 1, "{ EM4X RFIDs... }"},
+
{"flexdemod", CmdFlexdemod, 1, "Demodulate samples for FlexPass"},
- {"hid", CmdLFHID, 1, "{ HID RFIDs... }"},
- {"io", CmdLFIO, 1, "{ ioProx tags... }"},
{"indalademod", CmdIndalaDemod, 1, "['224'] -- Demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"},
{"indalaclone", CmdIndalaClone, 1, "<UID> ['l']-- Clone Indala to T55x7 (tag must be in antenna)(UID in HEX)(option 'l' for 224 UID"},
+ {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
+
+
{"read", CmdLFRead, 0, "['h' or <divisor>] -- Read 125/134 kHz LF ID-only tag (option 'h' for 134, alternatively: f=12MHz/(divisor+1))"},
{"sim", CmdLFSim, 0, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
{"simbidir", CmdLFSimBidir, 0, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
{"simman", CmdLFSimManchester, 0, "<Clock> <Bitstream> [GAP] Simulate arbitrary Manchester LF tag"},
{"snoop", CmdLFSnoop, 0, "['l'|'h'|<divisor>] [trigger threshold]-- Snoop LF (l:125khz, h:134khz)"},
- {"ti", CmdLFTI, 1, "{ TI RFIDs... }"},
- {"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders... }"},
- {"vchdemod", CmdVchDemod, 1, "['clone'] -- Demodulate samples for VeriChip"},
- {"t55xx", CmdLFT55XX, 1, "{ T55xx RFIDs... }"},
- {"pcf7931", CmdLFPCF7931, 1, "{PCF7931 RFIDs...}"},
+
+ {"em4x", CmdLFEM4X, 1, "{ EM4X tags }"},
+ {"hid", CmdLFHID, 1, "{ HID tags }"},
+ {"hitag", CmdLFHitag, 1, "{ Hitag tags and transponders }"},
+ {"io", CmdLFIO, 1, "{ ioProx tags }"},
+ {"pcf7931", CmdLFPCF7931, 1, "{ PCF7931 tags }"},
+ {"ti", CmdLFTI, 1, "{ TI tags }"},
+ {"t55xx", CmdLFT55XX, 1, "{ T55xx tags }"},
+
{NULL, NULL, 0, NULL}
};
return 0;
}
-
int CmdIOProxDemod(const char *Cmd){
if (GraphTraceLen < 4800) {
PrintAndLog("too short; need at least 4800 samples");
return 0;
}
-
GraphTraceLen = 4800;
for (int i = 0; i < GraphTraceLen; ++i) {
- if (GraphBuffer[i] < 0) {
- GraphBuffer[i] = 0;
- } else {
- GraphBuffer[i] = 1;
- }
+ GraphBuffer[i] = (GraphBuffer[i] < 0) ? 0 : 1;
}
RepaintGraphWindow();
return 0;
static command_t CommandTable[] =
{
- {"help", CmdHelp, 1, "This help"},
- {"demod", CmdIOProxDemod, 1, "Demodulate Stream"},
- {"fskdemod", CmdIODemodFSK, 1, "Demodulate ioProx Tag"},
- {"clone", CmdIOClone, 1, "Clone ioProx Tag"},
+ {"help", CmdHelp, 1, "This help"},
+ {"demod", CmdIOProxDemod, 1, "Demodulate Stream"},
+ {"fskdemod", CmdIODemodFSK, 1, "Demodulate ioProx Tag"},
+ {"clone", CmdIOClone, 1, "Clone ioProx Tag"},
{NULL, NULL, 0, NULL}
};
char cmdp = param_getchar(Cmd, 0);\r
char s[20];\r
uint8_t pwd[4] = {0x00};\r
-\r
\r
if (strlen(Cmd)>1 || cmdp == 'h' || cmdp == 'H') {\r
PrintAndLog("Usage: lf t55xx dump <password>");\r
}\r
}\r
\r
-\r
for ( int i = 0; i <8; ++i){\r
*s = 0;\r
if ( hasPwd ) {\r
return 0;\r
}\r
\r
+int CmdIceFsk(const char *Cmd){\r
+ //uint8_t bits[1000] = {0x00};\r
+ //uint8_t * bitstream = bits;\r
+ iceFsk3(GraphBuffer, LF_TRACE_BUFF_SIZE);\r
+ \r
+ RepaintGraphWindow();\r
+ return 0;\r
+}\r
+\r
char * GetBitRateStr(uint32_t id){\r
static char buf[40];\r
char *retStr = buf;\r
\r
switch (id){\r
case 0: \r
- sprintf(retStr,"%d - direct",id);\r
+ sprintf(retStr,"%d - DIRECT (ASK/NRZ)",id);\r
break;\r
case 1:\r
sprintf(retStr,"%d - PSK 1 phase change when input changes",id);\r
static command_t CommandTable[] =\r
{\r
{"help", CmdHelp, 1, "This help"},\r
- {"rd", CmdReadBlk, 0, "<Block> -- Read T55xx block data (page 0)"},\r
- {"rdPWD", CmdReadBlkPWD, 0, "<Block> <Password> -- Read T55xx block data in password mode(page 0)"},\r
- {"wr", CmdWriteBlk, 0, "<Data> <Block> -- Write T55xx block data (page 0)"},\r
- {"wrPWD", CmdWriteBlkPWD, 0, "<Data> <Block> <Password> -- Write T55xx block data in password mode(page 0)"},\r
- {"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1)"},\r
- {"info", CmdInfo, 0, "Read T55xx configuration data (page 0 / block 0"},\r
- {"dump", CmdDump, 0, "Dump T55xx card block 0-7 (is possible)"},\r
+ {"rd", CmdReadBlk, 0, "<block> -- Read T55xx block data (page 0)"},\r
+ {"rdPWD", CmdReadBlkPWD, 0, "<block> <password> -- Read T55xx block data with password mode"},\r
+ {"wr", CmdWriteBlk, 0, "<data> <block> -- Write T55xx block data (page 0)"},\r
+ {"wrPWD", CmdWriteBlkPWD, 0, "<data> <block> <password> -- Write T55xx block data with password"},\r
+ {"trace", CmdReadTrace, 0, "Read T55xx traceability data (page 1 / blk 0-1)"},\r
+ {"info", CmdInfo, 0, "Read T55xx configuration data (page0 /blk 0)"},\r
+ {"dump", CmdDump, 0, "[password] Dump T55xx card block 0-7. optional with password"},\r
+ {"fsk", CmdIceFsk, 0, "FSK demod"},\r
{NULL, NULL, 0, NULL}\r
};\r
\r
int CmdWriteBLkPWD(const char *Cmd);\r
int CmdReadTrace(const char *Cmd);\r
int CmdInfo(const char *Cmd);\r
+int CmdIceFsk(const char *Cmd);\r
char * GetBitRateStr(uint32_t id);\r
char * GetSaferStr(uint32_t id);\r
char * GetModulationStr( uint32_t id);\r
{
sample_buf_len = 0;
sample_buf = dest;
-// start_index = ((start_index/12)*12);
-// int n = start_index + bytes;
- /*
- if (n % 48 != 0) {
- PrintAndLog("bad len in GetFromBigBuf");
- return;
- }
- */
UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {start_index, bytes, 0}};
SendCommand(&c);
-/*
- for (int i = start_index; i < n; i += 48) {
- UsbCommand c = {CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K, {i, 0, 0}};
- SendCommand(&c);
-// WaitForResponse(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K);
-// memcpy(dest+(i*4), sample_buf, 48);
- }
-*/
}
#include <time.h>
#include <readline/readline.h>
#include <pthread.h>
-#include "ui.h"
#include "loclass/cipherutils.h"
+#include "ui.h"
+
+//#include <liquid/liquid.h>
+#define M_PI 3.14159265358979323846264338327
double CursorScaleFactor;
int PlotGridX, PlotGridY, PlotGridXdefault= 64, PlotGridYdefault= 64;
// PrintPaddedManchester(bitStream, bitlength, clock);
memcpy(dataout, bitStream, bitlength);
-
- free(bitStream);
return bitlength;
}
if ( mod > 0 )
PrintAndLog(" %s", sprint_bin(bitStream+i, mod) );
-}
\ No newline at end of file
+}
+
+void iceFsk(int * data, const size_t len){
+
+ //34359738 == 125khz (2^32 / 125) =
+
+ // parameters
+ float phase_offset = 0.00f; // carrier phase offset
+ float frequency_offset = 0.30f; // carrier frequency offset
+ float wn = 0.01f; // pll bandwidth
+ float zeta = 0.707f; // pll damping factor
+ float K = 1000; // pll loop gain
+ size_t n = len; // number of samples
+
+ // generate loop filter parameters (active PI design)
+ float t1 = K/(wn*wn); // tau_1
+ float t2 = 2*zeta/wn; // tau_2
+
+ // feed-forward coefficients (numerator)
+ float b0 = (4*K/t1)*(1.+t2/2.0f);
+ float b1 = (8*K/t1);
+ float b2 = (4*K/t1)*(1.-t2/2.0f);
+
+ // feed-back coefficients (denominator)
+ // a0 = 1.0 is implied
+ float a1 = -2.0f;
+ float a2 = 1.0f;
+
+ // filter buffer
+ float v0=0.0f, v1=0.0f, v2=0.0f;
+
+ // initialize states
+ float phi = phase_offset; // input signal's initial phase
+ float phi_hat = 0.0f; // PLL's initial phase
+
+ unsigned int i;
+ float complex x,y;
+ float complex output[n];
+
+ for (i=0; i<n; i++) {
+ // INPUT SIGNAL
+ x = data[i];
+ phi += frequency_offset;
+
+ // generate complex sinusoid
+ y = cosf(phi_hat) + _Complex_I*sinf(phi_hat);
+
+ output[i] = y;
+
+ // compute error estimate
+ float delta_phi = cargf( x * conjf(y) );
+
+
+ // print results to standard output
+ printf(" %6u %12.8f %12.8f %12.8f %12.8f %12.8f\n",
+ i,
+ crealf(x), cimagf(x),
+ crealf(y), cimagf(y),
+ delta_phi);
+
+ // push result through loop filter, updating phase estimate
+
+ // advance buffer
+ v2 = v1; // shift center register to upper register
+ v1 = v0; // shift lower register to center register
+
+ // compute new lower register
+ v0 = delta_phi - v1*a1 - v2*a2;
+
+ // compute new output
+ phi_hat = v0*b0 + v1*b1 + v2*b2;
+
+ }
+
+ for (i=0; i<len; ++i){
+ data[i] = (int)crealf(output[i]);
+ }
+}
+
+/* Sliding DFT
+ Smooths out
+*/
+void iceFsk2(int * data, const size_t len){
+
+ int i, j;
+ int output[len];
+
+ // for (i=0; i<len-5; ++i){
+ // for ( j=1; j <=5; ++j) {
+ // output[i] += data[i*j];
+ // }
+ // output[i] /= 5;
+ // }
+ int rest = 127;
+ int tmp =0;
+ for (i=0; i<len; ++i){
+ if ( data[i] < 127)
+ output[i] = 0;
+ else {
+ tmp = (100 * (data[i]-rest)) / rest;
+ output[i] = (tmp > 60)? 100:0;
+ }
+ }
+
+ for (j=0; j<len; ++j)
+ data[j] = output[j];
+}
+
+void iceFsk3(int * data, const size_t len){
+
+ int i,j;
+ int output[len];
+ float fc = 0.1125f; // center frequency
+
+ // create very simple low-pass filter to remove images (2nd-order Butterworth)
+ float complex iir_buf[3] = {0,0,0};
+ float b[3] = {0.003621681514929, 0.007243363029857, 0.003621681514929};
+ float a[3] = {1.000000000000000, -1.822694925196308, 0.837181651256023};
+
+ // process entire input file one sample at a time
+ float sample = 0; // input sample read from file
+ float complex x_prime = 1.0f; // save sample for estimating frequency
+ float complex x;
+
+ for (i=0; i<len; ++i) {
+
+ sample = data[i];
+
+ // remove DC offset and mix to complex baseband
+ x = (sample - 127.5f) * cexpf( _Complex_I * 2 * M_PI * fc * i );
+
+ // apply low-pass filter, removing spectral image (IIR using direct-form II)
+ iir_buf[2] = iir_buf[1];
+ iir_buf[1] = iir_buf[0];
+ iir_buf[0] = x - a[1]*iir_buf[1] - a[2]*iir_buf[2];
+ x = b[0]*iir_buf[0] +
+ b[1]*iir_buf[1] +
+ b[2]*iir_buf[2];
+
+ // compute instantaneous frequency by looking at phase difference
+ // between adjacent samples
+ float freq = cargf(x*conjf(x_prime));
+ x_prime = x; // retain this sample for next iteration
+
+ output[i] =(freq > 0)? 10 : -10;
+ }
+
+ // show data
+ for (j=0; j<len; ++j)
+ data[j] = output[j];
+
+ CmdLtrim("30");
+
+ // zero crossings.
+ for (j=0; j<len; ++j){
+ if ( data[j] == 10) break;
+ }
+ int startOne =j;
+
+ for (;j<len; ++j){
+ if ( data[j] == -10 ) break;
+ }
+ int stopOne = j-1;
+
+ int fieldlen = stopOne-startOne;
+ printf("FIELD Length: %d \n", fieldlen);
+
+
+ // FSK sequence start == 000111
+ int startPos = 0;
+ for (i =0; i<len; ++i){
+ int dec = 0;
+ for ( j = 0; j < 6*fieldlen; ++j){
+ dec += data[i + j];
+ }
+ if (dec == 0) {
+ startPos = i;
+ break;
+ }
+ }
+
+ printf("000111 position: %d \n", startPos);
+
+ startPos += 6*fieldlen+1;
+
+ printf("BINARY\n");
+ printf("R/40 : ");
+ for (i =startPos ; i < len; i += 40){
+ if ( data[i] > 0 )
+ printf("1");
+ else
+ printf("0");
+ }
+ printf("\n");
+
+ printf("R/50 : ");
+ for (i =startPos ; i < len; i += 50){
+ if ( data[i] > 0 )
+ printf("1");
+ else
+ printf("0");
+ }
+ printf("\n");
+
+}
+
+float complex cexpf (float complex Z)
+{
+ float complex Res;
+ double rho = exp (__real__ Z);
+ __real__ Res = rho * cosf(__imag__ Z);
+ __imag__ Res = rho * sinf(__imag__ Z);
+ return Res;
+}
#ifndef UI_H__
#define UI_H__
+#include <math.h>
+#include <complex.h>
#include "util.h"
void ShowGui(void);
void ManchesterDiffDecodedString( const uint8_t *bitStream, size_t len, uint8_t invert );
int ManchesterConvertFrom255(const int * data, const size_t len, uint8_t * dataout, int high, int low, int clock, int startIndex);
int ManchesterConvertFrom1(const int * data, const size_t len, uint8_t * dataout, int clock, int startIndex);
+void iceFsk(int * data, const size_t len);
+void iceFsk2(int * data, const size_t len);
+void iceFsk3(int * data, const size_t len);
#endif
my $clean = 2;
my @compiletime = gmtime();
-my $fullgitinfo = $gitbranch . '/' . $gitversion;
+my $fullgitinfo = 'iceman' . $gitbranch . '/' . $gitversion;
$fullgitinfo =~ s/(\s)//g;