From b439c76c6e7b016793f4c4dd84e0586bacdce6f8 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Thu, 14 Sep 2017 11:13:10 +0200 Subject: [PATCH] CHG: changed name on define. Its now called CMD_UPLOAD_SIM_SAMPLES_125K .. Since we upload to device. --- armsrc/appmain.c | 5 ++-- client/cmdlf.c | 50 +++++++++++++++++++++--------------- client/hid-flasher/usb_cmd.h | 2 +- include/usb_cmd.h | 2 +- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index b9cff6201..6de04383b 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -1000,12 +1000,13 @@ void UsbPacketReceived(uint8_t *packet, int len) { LED_B_OFF(); break; } - case CMD_DOWNLOADED_SIM_SAMPLES_125K: { + case CMD_UPLOAD_SIM_SAMPLES_125K: { // iceman; since changing fpga_bitstreams clears bigbuff, Its better to call it before. // to be able to use this one for uploading data to device // arg1 = 0 upload for LF usage // 1 upload for HF usage - if ( c->arg[1] == 0 ) + #define FPGA_LF 1 + if ( c->arg[1] == FPGA_LF ) FpgaDownloadAndGo(FPGA_BITSTREAM_LF); else FpgaDownloadAndGo(FPGA_BITSTREAM_HF); diff --git a/client/cmdlf.c b/client/cmdlf.c index 72469a462..22d0bc259 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -75,16 +75,27 @@ int usage_lf_config(void) { return 0; } int usage_lf_simfsk(void) { - PrintAndLog("Usage: lf simfsk [c ] [i] [H ] [L ] [d ]"); + PrintAndLog("Usage: lf simfsk [h] [c ] [H ] [L ] [d ]"); + PrintAndLog("there are about four FSK modulations to know of."); + PrintAndLog("FSK1 - where fc/8 = high and fc/5 = low"); + PrintAndLog("FSK1a - is inverted FSK1, ie: fc/5 = high and fc/8 = low"); + PrintAndLog("FSK2 - where fc/10 = high and fc/8 = low"); + PrintAndLog("FSK2a - is inverted FSK2, ie: fc/10 = high and fc/8 = low"); + PrintAndLog(""); PrintAndLog("Options:"); PrintAndLog(" h This help"); PrintAndLog(" c Manually set clock - can autodetect if using DemodBuffer"); - PrintAndLog(" i invert data"); PrintAndLog(" H Manually set the larger Field Clock"); PrintAndLog(" L Manually set the smaller Field Clock"); - //PrintAndLog(" s TBD- -to enable a gap between playback repetitions - default: no gap"); + //PrintAndLog(" s TBD- -STT to enable a gap between playback repetitions - default: no gap"); PrintAndLog(" d Data to sim as hex - omit to sim from DemodBuffer"); PrintAndLog("\n NOTE: if you set one clock manually set them all manually"); + PrintAndLog("\nSamples:"); + PrintAndLog(" lf simfsk c 40 H 8 L 5 d 010203 - FSK1 rf/40 data 010203"); + PrintAndLog(" lf simfsk c 40 H 5 L 8 d 010203 - FSK1a rf/40 data 010203"); + PrintAndLog(" lf simfsk c 64 H 10 L 8 d 010203 - FSK2 rf/64 data 010203"); + PrintAndLog(" lf simfsk c 64 H 8 L 10 d 010203 - FSK2a rf/64 data 010203"); + PrintAndLog(""); return 0; } int usage_lf_simask(void) { @@ -400,9 +411,10 @@ static void ChkBitstream(const char *str) { //Attempt to simulate any wave in buffer (one bit per output sample) // converts GraphBuffer to bitstream (based on zero crossings) if needed. int CmdLFSim(const char *Cmd) { - int i,j; - static int gap; +#define FPGA_LF 1 +#define FPGA_HF 2 + int gap = 0; sscanf(Cmd, "%i", &gap); // convert to bitstream if necessary @@ -410,12 +422,13 @@ int CmdLFSim(const char *Cmd) { if (g_debugMode) printf("DEBUG: Sending [%d bytes]\n", GraphTraceLen); + //can send only 512 bits at a time (1 byte sent per bit...) - for (i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) { - UsbCommand c = {CMD_DOWNLOADED_SIM_SAMPLES_125K, {i, 0, 0}}; + for (uint16_t i = 0; i < GraphTraceLen; i += USB_CMD_DATA_SIZE) { + UsbCommand c = {CMD_UPLOAD_SIM_SAMPLES_125K, {i, FPGA_LF, 0}}; - for (j = 0; j < USB_CMD_DATA_SIZE; j++) + for (uint16_t j = 0; j < USB_CMD_DATA_SIZE; j++) c.d.asBytes[j] = GraphBuffer[i+j]; clearCommandBuffer(); @@ -438,21 +451,16 @@ int CmdLFfskSim(const char *Cmd) { //might be able to autodetect FCs and clock from Graphbuffer if using demod buffer // otherwise will need FChigh, FClow, Clock, and bitstream uint8_t fcHigh = 0, fcLow = 0, clk = 0; - uint8_t invert = 0; - bool errors = false; + bool errors = false, separator = false; char hexData[32] = {0x00}; // store entered hex data uint8_t data[255] = {0x00}; int dataLen = 0; - uint8_t cmdp = 0; + uint8_t cmdp = 0; while(param_getchar(Cmd, cmdp) != 0x00 && !errors) { switch(param_getchar(Cmd, cmdp)){ case 'h': return usage_lf_simfsk(); - case 'i': - invert = 1; - cmdp++; - break; case 'c': errors |= param_getdec(Cmd, cmdp+1, &clk); cmdp += 2; @@ -465,10 +473,10 @@ int CmdLFfskSim(const char *Cmd) { errors |= param_getdec(Cmd, cmdp+1, &fcLow); cmdp += 2; break; - //case 's': - // separator = 1; - // cmdp++; - // break; + case 's': + separator = 1; + cmdp++; + break; case 'd': dataLen = param_getstr(Cmd, cmdp+1, hexData); if (dataLen == 0) @@ -514,7 +522,7 @@ int CmdLFfskSim(const char *Cmd) { uint16_t arg1, arg2; arg1 = fcHigh << 8 | fcLow; - arg2 = invert << 8 | clk; + arg2 = separator << 8 | clk; size_t size = DemodBufferLen; if (size > USB_CMD_DATA_SIZE) { PrintAndLog("DemodBuffer too long for current implementation - length: %d - max: %d", size, USB_CMD_DATA_SIZE); @@ -525,6 +533,8 @@ int CmdLFfskSim(const char *Cmd) { memcpy(c.d.asBytes, DemodBuffer, size); clearCommandBuffer(); SendCommand(&c); + + setClockGrid(clk, 0); return 0; } diff --git a/client/hid-flasher/usb_cmd.h b/client/hid-flasher/usb_cmd.h index 133a9eda9..8147775d8 100644 --- a/client/hid-flasher/usb_cmd.h +++ b/client/hid-flasher/usb_cmd.h @@ -64,7 +64,7 @@ typedef struct { #define CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K 0x0206 #define CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K 0x0207 #define CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K 0x0208 -#define CMD_DOWNLOADED_SIM_SAMPLES_125K 0x0209 +#define CMD_UPLOAD_SIM_SAMPLES_125K 0x0209 #define CMD_SIMULATE_TAG_125K 0x020A #define CMD_HID_DEMOD_FSK 0x020B #define CMD_HID_SIM_TAG 0x020C diff --git a/include/usb_cmd.h b/include/usb_cmd.h index 88f8652bf..d941d4e2c 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -75,7 +75,7 @@ typedef struct{ #define CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K 0x0206 #define CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K 0x0207 #define CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K 0x0208 -#define CMD_DOWNLOADED_SIM_SAMPLES_125K 0x0209 +#define CMD_UPLOAD_SIM_SAMPLES_125K 0x0209 #define CMD_SIMULATE_TAG_125K 0x020A #define CMD_HID_DEMOD_FSK 0x020B #define CMD_HID_SIM_TAG 0x020C