From: bushing Date: Tue, 22 Dec 2009 12:34:24 +0000 (+0000) Subject: change usb_cmd struct to be more sane X-Git-Tag: v1.0.0~442 X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/commitdiff_plain/3a8464f0679d86904aa4ae2abb0cafe02e222ce8?ds=sidebyside change usb_cmd struct to be more sane wean ourselves off translate.h --- diff --git a/client/command.cpp b/client/command.cpp index 0214a0ab..108cd770 100644 --- a/client/command.cpp +++ b/client/command.cpp @@ -34,7 +34,7 @@ static void GetFromBigBuf(BYTE *dest, int bytes) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -91,7 +91,7 @@ static void CmdHi14read(char *str) { UsbCommand c; c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -104,30 +104,30 @@ static void CmdSri512read(char *str) { UsbCommand c; c.cmd = CMD_READ_SRI512_TAG; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } - -/* New command to read the contents of a SRIX4K tag - * SRIX4K tags are ISO14443-B modulated memory tags, - * this command just dumps the contents of the memory/ - */ -static void CmdSrix4kread(char *str) -{ - UsbCommand c; - c.cmd = CMD_READ_SRIX4K_TAG; - c.ext1 = atoi(str); - SendCommand(&c, FALSE); -} - - + +/* New command to read the contents of a SRIX4K tag + * SRIX4K tags are ISO14443-B modulated memory tags, + * this command just dumps the contents of the memory/ + */ +static void CmdSrix4kread(char *str) +{ + UsbCommand c; + c.cmd = CMD_READ_SRIX4K_TAG; + c.arg[0] = atoi(str); + SendCommand(&c, FALSE); +} + + // ## New command static void CmdHi14areader(char *str) { UsbCommand c; c.cmd = CMD_READER_ISO_14443a; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -136,7 +136,7 @@ static void CmdHi15reader(char *str) { UsbCommand c; c.cmd = CMD_READER_ISO_15693; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -145,7 +145,7 @@ static void CmdHi15tag(char *str) { UsbCommand c; c.cmd = CMD_SIMTAG_ISO_15693; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -153,7 +153,7 @@ static void CmdHi14read_sim(char *str) { UsbCommand c; c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -161,13 +161,13 @@ static void CmdHi14readt(char *str) { UsbCommand c; c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); //CmdHisamplest(str); while(CmdHisamplest(str,atoi(str))==0) { c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } RepaintGraphWindow(); @@ -201,8 +201,8 @@ static void CmdHi14asim(char *str) // ## simulate iso14443a tag c.cmd = CMD_SIMULATE_TAG_ISO_14443a; // c.ext should be set to *str or convert *str to the correct format for a uid - c.ext1 = hi; - c.ext2 = lo; + c.arg[0] = hi; + c.arg[1] = lo; PrintToScrollback("Emulating 14443A TAG with UID %x%16x", hi, lo); SendCommand(&c, FALSE); } @@ -681,13 +681,13 @@ static void CmdLosim(char *str) c.d.asBytes[j] = GraphBuffer[i+j]; } c.cmd = CMD_DOWNLOADED_SIM_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); } UsbCommand c; c.cmd = CMD_SIMULATE_TAG_125K; - c.ext1 = GraphTraceLen; + c.arg[0] = GraphTraceLen; SendCommand(&c, FALSE); } @@ -695,8 +695,8 @@ static void CmdLosimBidir(char *str) { UsbCommand c; c.cmd = CMD_LF_SIMULATE_BIDIR; - c.ext1 = 47; /* Set ADC to twice the carrier for a slight supersampling */ - c.ext2 = 384; + c.arg[0] = 47; /* Set ADC to twice the carrier for a slight supersampling */ + c.arg[1] = 384; SendCommand(&c, FALSE); } @@ -705,9 +705,9 @@ static void CmdLoread(char *str) UsbCommand c; // 'h' means higher-low-frequency, 134 kHz if(*str == 'h') { - c.ext1 = 1; + c.arg[0] = 1; } else if (*str == '\0') { - c.ext1 = 0; + c.arg[0] = 0; } else { PrintToScrollback("use 'loread' or 'loread h'"); return; @@ -721,9 +721,9 @@ static void CmdDetectReader(char *str) UsbCommand c; // 'l' means LF - 125/134 kHz if(*str == 'l') { - c.ext1 = 1; + c.arg[0] = 1; } else if (*str == 'h') { - c.ext1 = 2; + c.arg[0] = 2; } else if (*str != '\0') { PrintToScrollback("use 'detectreader' or 'detectreader l' or 'detectreader h'"); return; @@ -741,7 +741,7 @@ static void CmdLoCommandRead(char *str) UsbCommand c; c.cmd = CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K; - sscanf(str, "%i %i %i %s %s", &c.ext1, &c.ext2, &c.ext3, (char *) &c.d.asBytes,(char *) &dummy+1); + sscanf(str, "%i %i %i %s %s", &c.arg[0], &c.arg[1], &c.arg[2], (char *) &c.d.asBytes,(char *) &dummy+1); // in case they specified 'h' strcpy((char *)&c.d.asBytes + strlen((char *)c.d.asBytes), dummy); SendCommand(&c, FALSE); @@ -760,7 +760,7 @@ static void CmdLosamples(char *str) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -787,7 +787,7 @@ static void CmdBitsamples(char *str) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -818,7 +818,7 @@ static void CmdHisamples(char *str) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -850,7 +850,7 @@ static int CmdHisamplest(char *str, int nrlow) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -922,7 +922,7 @@ static void CmdHexsamples(char *str) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -966,7 +966,7 @@ static void CmdHisampless(char *str) for(i = 0; i < n; i += 12) { UsbCommand c; c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K; - c.ext1 = i; + c.arg[0] = i; SendCommand(&c, FALSE); ReceiveCommand(&c); if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) { @@ -1577,8 +1577,8 @@ static void CmdTIWrite(char *str) int res=0; c.cmd = CMD_WRITE_TI_TYPE; - res = sscanf(str, "0x%x 0x%x 0x%x ", &c.ext1, &c.ext2, &c.ext3); - if (res == 2) c.ext3=0; + res = sscanf(str, "0x%x 0x%x 0x%x ", &c.arg[0], &c.arg[1], &c.arg[2]); + if (res == 2) c.arg[2]=0; if (res<2) PrintToScrollback("Please specify the data as two hex strings, optionally the CRC as a third"); else @@ -2809,8 +2809,8 @@ static void CmdHIDsimTAG(char *str) PrintToScrollback("Emulating tag with ID %x%16x", hi, lo); c.cmd = CMD_HID_SIM_TAG; - c.ext1 = hi; - c.ext2 = lo; + c.arg[0] = hi; + c.arg[1] = lo; SendCommand(&c, FALSE); } @@ -2818,7 +2818,7 @@ static void CmdReadmem(char *str) { UsbCommand c; c.cmd = CMD_READ_MEM; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -2833,7 +2833,7 @@ static void CmdLcdReset(char *str) { UsbCommand c; c.cmd = CMD_LCD_RESET; - c.ext1 = atoi(str); + c.arg[0] = atoi(str); SendCommand(&c, FALSE); } @@ -2844,7 +2844,7 @@ static void CmdLcd(char *str) c.cmd = CMD_LCD; sscanf(str, "%x %d", &i, &j); while (j--) { - c.ext1 = i&0x1ff; + c.arg[0] = i&0x1ff; SendCommand(&c, FALSE); } } @@ -2857,12 +2857,12 @@ static void CmdSetDivisor(char *str) { UsbCommand c; c.cmd = CMD_SET_LF_DIVISOR; - c.ext1 = atoi(str); - if (( c.ext1<0) || (c.ext1>255)) { + c.arg[0] = atoi(str); + if (( c.arg[0]<0) || (c.arg[0]>255)) { PrintToScrollback("divisor must be between 19 and 255"); } else { SendCommand(&c, FALSE); - PrintToScrollback("Divisor set, expected freq=%dHz", 12000000/(c.ext1+1)); + PrintToScrollback("Divisor set, expected freq=%dHz", 12000000/(c.arg[0]+1)); } } @@ -2871,13 +2871,13 @@ static void CmdSetMux(char *str) UsbCommand c; c.cmd = CMD_SET_ADC_MUX; if(strcmp(str, "lopkd") == 0) { - c.ext1 = 0; + c.arg[0] = 0; } else if(strcmp(str, "loraw") == 0) { - c.ext1 = 1; + c.arg[0] = 1; } else if(strcmp(str, "hipkd") == 0) { - c.ext1 = 2; + c.arg[0] = 2; } else if(strcmp(str, "hiraw") == 0) { - c.ext1 = 3; + c.arg[0] = 3; } SendCommand(&c, FALSE); } @@ -2957,7 +2957,7 @@ static struct { {"setlfdivisor", CmdSetDivisor, 0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"}, {"setmux", CmdSetMux, 0, " -- Set the ADC mux to a specific value"}, {"sri512read", CmdSri512read, 0, " -- Read contents of a SRI512 tag"}, - {"srix4kread", CmdSrix4kread, 0, " -- Read contents of a SRIX4K tag"}, + {"srix4kread", CmdSrix4kread, 0, " -- Read contents of a SRIX4K tag"}, {"tidemod", CmdTIDemod, 1, "Demodulate raw bits for TI-type LF tag"}, {"tiread", CmdTIRead, 0, "Read and decode a TI 134 kHz tag"}, {"tiwrite", CmdTIWrite, 0, "Write new data to a r/w TI 134 kHz tag"}, @@ -3049,27 +3049,27 @@ void UsbCommandReceived(UsbCommand *c) switch(c->cmd) { case CMD_DEBUG_PRINT_STRING: { char s[100]; - if(c->ext1 > 70 || c->ext1 < 0) { - c->ext1 = 0; + if(c->arg[0] > 70 || c->arg[0] < 0) { + c->arg[0] = 0; } - memcpy(s, c->d.asBytes, c->ext1); - s[c->ext1] = '\0'; + memcpy(s, c->d.asBytes, c->arg[0]); + s[c->arg[0]] = '\0'; PrintToScrollback("#db# %s", s); break; } case CMD_DEBUG_PRINT_INTEGERS: - PrintToScrollback("#db# %08x, %08x, %08x\r\n", c->ext1, c->ext2, c->ext3); + PrintToScrollback("#db# %08x, %08x, %08x\r\n", c->arg[0], c->arg[1], c->arg[2]); break; case CMD_MEASURED_ANTENNA_TUNING: { int peakv, peakf; int vLf125, vLf134, vHf; - vLf125 = c->ext1 & 0xffff; - vLf134 = c->ext1 >> 16; - vHf = c->ext2 & 0xffff;; - peakf = c->ext3 & 0xffff; - peakv = c->ext3 >> 16; + vLf125 = c->arg[0] & 0xffff; + vLf134 = c->arg[0] >> 16; + vHf = c->arg[1] & 0xffff;; + peakf = c->arg[2] & 0xffff; + peakv = c->arg[2] >> 16; PrintToScrollback(""); PrintToScrollback(""); PrintToScrollback("# LF antenna: %5.2f V @ 125.00 kHz", vLf125/1000.0); diff --git a/client/flasher.c b/client/flasher.c index e3043fa3..bcbe2d77 100644 --- a/client/flasher.c +++ b/client/flasher.c @@ -42,16 +42,16 @@ static void FlushPrevious(int translate) for(i = 0; i < 240; i += 48) { c.cmd = CMD_SETUP_WRITE; memcpy(c.d.asBytes, QueuedToSend+i, 48); - c.ext1 = (i/4); + c.arg[0] = (i/4); SendCommand(&c, TRUE); } c.cmd = CMD_FINISH_WRITE; - c.ext1 = (ExpectedAddr-1) & (~255); + c.arg[0] = (ExpectedAddr-1) & (~255); if(translate) { - c.ext1 -= PHYSICAL_FLASH_START; + c.arg[0] -= PHYSICAL_FLASH_START; } - printf("c.ext1 = %08x\r", c.ext1); + printf("c.arg[0] = %08x\r", c.arg[0]); memcpy(c.d.asBytes, QueuedToSend+240, 16); SendCommand(&c, TRUE); @@ -151,14 +151,14 @@ static int PrepareFlash(struct partition *p, const char *filename, unsigned int if(state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) { UsbCommand c; c.cmd = CMD_START_FLASH; - c.ext1 = p->start; - c.ext2 = p->end; + c.arg[0] = p->start; + c.arg[1] = p->end; /* Only send magic when flashing bootrom */ if(p->precious) { - c.ext3 = START_FLASH_MAGIC; + c.arg[2] = START_FLASH_MAGIC; } else { - c.ext3 = 0; + c.arg[2] = 0; } SendCommand(&c, TRUE); translate = 0; @@ -196,7 +196,7 @@ static unsigned int GetProxmarkState(void) state = DEVICE_INFO_FLAG_CURRENT_MODE_OS; break; case CMD_DEVICE_INFO: - state = resp.ext1; + state = resp.arg[0]; break; default: fprintf(stderr, "Couldn't get proxmark state, bad response type: 0x%04X\n", resp.cmd); diff --git a/client/prox.cpp b/client/prox.cpp index 4b80e3cc..86a0ff45 100644 --- a/client/prox.cpp +++ b/client/prox.cpp @@ -253,16 +253,16 @@ static void FlushPrevious(int translate) for(i = 0; i < 240; i += 48) { c.cmd = CMD_SETUP_WRITE; memcpy(c.d.asBytes, QueuedToSend+i, 48); - c.ext1 = (i/4); + c.arg[0] = (i/4); SendCommand(&c, TRUE); } c.cmd = CMD_FINISH_WRITE; - c.ext1 = (ExpectedAddr-1) & (~255); + c.arg[0] = (ExpectedAddr-1) & (~255); if(translate) { - c.ext1 -= PHYSICAL_FLASH_START; + c.arg[0] -= PHYSICAL_FLASH_START; } - printf("Flashing address: %08x\r", c.ext1); + printf("Flashing address: %08x\r", c.arg[0]); memcpy(c.d.asBytes, QueuedToSend+240, 16); SendCommand(&c, TRUE); @@ -362,14 +362,14 @@ static int PrepareFlash(struct partition *p, const char *filename, unsigned int if(state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) { UsbCommand c; c.cmd = CMD_START_FLASH; - c.ext1 = p->start; - c.ext2 = p->end; + c.arg[0] = p->start; + c.arg[1] = p->end; /* Only send magic when flashing bootrom */ if(p->precious) { - c.ext3 = START_FLASH_MAGIC; + c.arg[2] = START_FLASH_MAGIC; } else { - c.ext3 = 0; + c.arg[2] = 0; } SendCommand(&c, TRUE); translate = 0; @@ -407,7 +407,7 @@ static unsigned int GetProxmarkState(void) state = DEVICE_INFO_FLAG_CURRENT_MODE_OS; break; case CMD_DEVICE_INFO: - state = resp.ext1; + state = resp.arg[0]; break; default: fprintf(stderr, "Couldn't get proxmark state, bad response type: 0x%04X\n", resp.cmd); diff --git a/client/prox.h b/client/prox.h index aeb6dfea..21ee8c1a 100644 --- a/client/prox.h +++ b/client/prox.h @@ -1,15 +1,24 @@ #ifndef __PROX_H #define __PROX_H - +#ifdef _MSC_VER +typedef DWORD uint32_t; +typedef BYTE uint8_t; +typedef WORD uint16_t; +#define bool BOOL +#else +#include +#include +#endif #include "../include/usb_cmd.h" // prox.cpp void ReceiveCommand(UsbCommand *c); -BOOL ReceiveCommandPoll(UsbCommand *c); -void SendCommand(UsbCommand *c, BOOL wantAck); +bool ReceiveCommandPoll(UsbCommand *c); +void SendCommand(UsbCommand *c, bool); +void wait_for_response(uint32_t command_type); // gui.cpp -void ShowGui(); +void ShowGui(void); void HideGraphWindow(void); void ShowGraphWindow(void); void RepaintGraphWindow(void); @@ -24,7 +33,7 @@ extern int offline; // command.cpp static void CmdBuffClear(char *str); -static void GetFromBigBuf(BYTE *dest, int bytes); +static void GetFromBigBuf(uint8_t *dest, int bytes); static void CmdReset(char *str); static void CmdQuit(char *str); static void CmdEM410xread(char *str); @@ -61,7 +70,7 @@ static void CmdHisamples(char *str); static int CmdHisamplest(char *str, int nrlow); static void CmdHexsamples(char *str); static void CmdHisampless(char *str); -static WORD Iso15693Crc(BYTE *v, int n); +static uint16_t Iso15693Crc(uint8_t *v, int n); static void CmdHi14bdemod(char *str); static void CmdHi14list(char *str); static void CmdHi14alist(char *str); diff --git a/client/snooper.c b/client/snooper.c index 9a92e84d..e382eddf 100644 --- a/client/snooper.c +++ b/client/snooper.c @@ -6,7 +6,7 @@ #include #include -#include "translate.h" +//#include "translate.h" #include "prox.h" #include "proxmark3.h" diff --git a/client/usb.c b/client/usb.c index c326aeca..8f5f38a7 100644 --- a/client/usb.c +++ b/client/usb.c @@ -1,11 +1,12 @@ #include #include +#include +#include #include #include #include #include -#include "translate.h" #include "prox.h" #include "proxmark3.h" @@ -14,7 +15,7 @@ static unsigned int claimed_iface = 0; unsigned char return_on_error = 0; unsigned char error_occured = 0; -void SendCommand(UsbCommand *c, BOOL wantAck) { +void SendCommand(UsbCommand *c, bool wantAck) { int ret; #if 0 diff --git a/include/usb_cmd.h b/include/usb_cmd.h index 76b543f6..40e4dc8c 100644 --- a/include/usb_cmd.h +++ b/include/usb_cmd.h @@ -7,88 +7,111 @@ #ifndef __USB_CMD_H #define __USB_CMD_H +#ifdef _MSC_VER +typedef DWORD uint32_t; +typedef BYTE uint8_t; +#define PACKED +// stuff +#else +#include +#include +#define PACKED __attribute__((packed)) +#endif typedef struct { - DWORD cmd; - DWORD ext1; - DWORD ext2; - DWORD ext3; + uint32_t cmd; + uint32_t arg[3]; union { - BYTE asBytes[48]; - DWORD asDwords[12]; + uint8_t asBytes[48]; + uint32_t asDwords[12]; } d; -} UsbCommand; +} PACKED UsbCommand; // For the bootloader -#define CMD_DEVICE_INFO 0x0000 -#define CMD_SETUP_WRITE 0x0001 -#define CMD_FINISH_WRITE 0x0003 -#define CMD_HARDWARE_RESET 0x0004 -#define CMD_START_FLASH 0x0005 -#define CMD_NACK 0x00fe -#define CMD_ACK 0x00ff +#define CMD_DEVICE_INFO 0x0000 +#define CMD_SETUP_WRITE 0x0001 +#define CMD_FINISH_WRITE 0x0003 +#define CMD_HARDWARE_RESET 0x0004 +#define CMD_START_FLASH 0x0005 +#define CMD_NACK 0x00fe +#define CMD_ACK 0x00ff // For general mucking around -#define CMD_DEBUG_PRINT_STRING 0x0100 -#define CMD_DEBUG_PRINT_INTEGERS 0x0101 -#define CMD_DEBUG_PRINT_BYTES 0x0102 -#define CMD_LCD_RESET 0x0103 -#define CMD_LCD 0x0104 -#define CMD_BUFF_CLEAR 0x0105 -#define CMD_READ_MEM 0x0106 -#define CMD_VERSION 0x0107 +#define CMD_DEBUG_PRINT_STRING 0x0100 +#define CMD_DEBUG_PRINT_INTEGERS 0x0101 +#define CMD_DEBUG_PRINT_BYTES 0x0102 +#define CMD_LCD_RESET 0x0103 +#define CMD_LCD 0x0104 +#define CMD_BUFF_CLEAR 0x0105 +#define CMD_READ_MEM 0x0106 +#define CMD_VERSION 0x0107 // For low-frequency tags -#define CMD_READ_TI_TYPE 0x0202 -#define CMD_WRITE_TI_TYPE 0x0203 -#define CMD_DOWNLOADED_RAW_BITS_TI_TYPE 0x0204 -#define CMD_ACQUIRE_RAW_ADC_SAMPLES_125K 0x0205 -#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_SIMULATE_TAG_125K 0x020A -#define CMD_HID_DEMOD_FSK 0x020B -#define CMD_HID_SIM_TAG 0x020C -#define CMD_SET_LF_DIVISOR 0x020D -#define CMD_LF_SIMULATE_BIDIR 0x020E -#define CMD_SET_ADC_MUX 0x020F +#define CMD_READ_TI_TYPE 0x0202 +#define CMD_WRITE_TI_TYPE 0x0203 +#define CMD_DOWNLOADED_RAW_BITS_TI_TYPE 0x0204 +#define CMD_ACQUIRE_RAW_ADC_SAMPLES_125K 0x0205 +#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_SIMULATE_TAG_125K 0x020A +#define CMD_HID_DEMOD_FSK 0x020B +#define CMD_HID_SIM_TAG 0x020C +#define CMD_SET_LF_DIVISOR 0x020D +#define CMD_LF_SIMULATE_BIDIR 0x020E +#define CMD_SET_ADC_MUX 0x020F /* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */ // For the 13.56 MHz tags -#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693 0x0300 -#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443 0x0301 -#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM 0x0302 -#define CMD_READ_SRI512_TAG 0x0303 -#define CMD_READ_SRIX4K_TAG 0x0304 -#define CMD_READER_ISO_15693 0x0310 -#define CMD_SIMTAG_ISO_15693 0x0311 -#define CMD_SIMULATE_TAG_HF_LISTEN 0x0380 -#define CMD_SIMULATE_TAG_ISO_14443 0x0381 -#define CMD_SNOOP_ISO_14443 0x0382 -#define CMD_SNOOP_ISO_14443a 0x0383 -#define CMD_SIMULATE_TAG_ISO_14443a 0x0384 -#define CMD_READER_ISO_14443a 0x0385 -#define CMD_SIMULATE_MIFARE_CARD 0x0386 -#define CMD_SIMULATE_TAG_LEGIC_RF 0x387 -#define CMD_READER_LEGIC_RF 0x388 +#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693 0x0300 +#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443 0x0301 +#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM 0x0302 +#define CMD_READ_SRI512_TAG 0x0303 +#define CMD_READ_SRIX4K_TAG 0x0304 +#define CMD_READER_ISO_15693 0x0310 +#define CMD_SIMTAG_ISO_15693 0x0311 +#define CMD_SIMULATE_TAG_HF_LISTEN 0x0380 +#define CMD_SIMULATE_TAG_ISO_14443 0x0381 +#define CMD_SNOOP_ISO_14443 0x0382 +#define CMD_SNOOP_ISO_14443a 0x0383 +#define CMD_SIMULATE_TAG_ISO_14443a 0x0384 +#define CMD_READER_ISO_14443a 0x0385 +#define CMD_SIMULATE_MIFARE_CARD 0x0386 +#define CMD_SIMULATE_TAG_LEGIC_RF 0x0387 +#define CMD_READER_LEGIC_RF 0x0388 // For measurements of the antenna tuning -#define CMD_MEASURE_ANTENNA_TUNING 0x0400 -#define CMD_MEASURED_ANTENNA_TUNING 0x0401 -#define CMD_LISTEN_READER_FIELD 0x0402 +#define CMD_MEASURE_ANTENNA_TUNING 0x0400 +#define CMD_MEASURED_ANTENNA_TUNING 0x0401 +#define CMD_LISTEN_READER_FIELD 0x0402 // For direct FPGA control -#define CMD_FPGA_MAJOR_MODE_OFF 0x0500 +#define CMD_FPGA_MAJOR_MODE_OFF 0x0500 + +#define CMD_UNKNOWN 0xFFFF + +// CMD_DEVICE_INFO response packet has flags in arg[0], flag definitions: +/* Whether a bootloader that understands the common_area is present */ +#define DEVICE_INFO_FLAG_BOOTROM_PRESENT (1<<0) + +/* Whether a osimage that understands the common_area is present */ +#define DEVICE_INFO_FLAG_OSIMAGE_PRESENT (1<<1) + +/* Set if the bootloader is currently executing */ +#define DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM (1<<2) + +/* Set if the OS is currently executing */ +#define DEVICE_INFO_FLAG_CURRENT_MODE_OS (1<<3) + +/* Set if this device understands the extend start flash command */ +#define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH (1<<4) -// CMD_DEVICE_INFO response packet has flags in ext1, flag definitions: -#define DEVICE_INFO_FLAG_BOOTROM_PRESENT (1<<0) /* Whether a bootloader that understands the common_area is present */ -#define DEVICE_INFO_FLAG_OSIMAGE_PRESENT (1<<1) /* Whether a osimage that understands the common_area is present */ -#define DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM (1<<2) /* Set if the bootloader is currently executing */ -#define DEVICE_INFO_FLAG_CURRENT_MODE_OS (1<<3) /* Set if the OS is currently executing */ -#define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH (1<<4) /* Set if this device understands the extend start flash command */ +/* CMD_START_FLASH may have three arguments: start of area to flash, + end of area to flash, optional magic. + The bootrom will not allow to overwrite itself unless this magic + is given as third parameter */ -// CMD_START_FLASH may have three arguments: start of area to flash, end of area to flash, optional magic defined below -#define START_FLASH_MAGIC 0x54494f44 /* The bootrom will not allow to overwrite itself unless this magic is given as third parameter */ +#define START_FLASH_MAGIC 0x54494f44 // 'DOIT' #endif