From 76346455d216abf24915f3141b36fab806cc2d41 Mon Sep 17 00:00:00 2001 From: marshmellow42 Date: Tue, 3 Nov 2015 20:18:16 -0500 Subject: [PATCH] minor lf updates/cleanup --- armsrc/lfops.c | 27 +++++++++++++++++++-------- client/cmddata.c | 8 -------- client/cmdlfem4x.c | 30 +++++++++++------------------- common/protocols.h | 2 +- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 5f21738a..01b88178 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -1312,6 +1312,9 @@ void CopyHIDtoT55x7(uint32_t hi2, uint32_t hi, uint32_t lo, uint8_t longFMT) { // load chip config block data[0] = T55x7_BITRATE_RF_50 | T55x7_MODULATION_FSK2a | last_block << T55x7_MAXBLOCK_SHIFT; + //TODO add selection of chip for Q5 or T55x7 + // data[0] = (((50-2)/2)<>32, id & 0xFFFFFFFF}; - if (card) { - clock = (card & 0xFF00) >> 8; - clock = (clock == 0) ? 64 : clock; - Dbprintf("Clock rate: %d", clock); - clock = GetT55xxClockBit(clock); + + clock = (card & 0xFF00) >> 8; + clock = (clock == 0) ? 64 : clock; + Dbprintf("Clock rate: %d", clock); + if (card & 0xFF) { //t55x7 + clock = GetT55xxClockBit(clock); if (clock == 0) { Dbprintf("Invalid clock rate: %d", clock); return; } - data[0] = clock | T55x7_MODULATION_MANCHESTER | (2 << T55x7_MAXBLOCK_SHIFT); - } else { - data[0] = (0x1F << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT); + } else { //t5555 (Q5) + clock = (clock-2)>>1; //n = (RF-2)/2 + data[0] = (clock << T5555_BITRATE_SHIFT) | T5555_MODULATION_MANCHESTER | (2 << T5555_MAXBLOCK_SHIFT); } WriteT55xx(data, 0, 3); diff --git a/client/cmddata.c b/client/cmddata.c index 22da1805..9fa29dd1 100644 --- a/client/cmddata.c +++ b/client/cmddata.c @@ -1130,8 +1130,6 @@ int CmdFSKdemodParadox(const char *Cmd) //print ioprox ID and some format details int CmdFSKdemodIO(const char *Cmd) { - //raw fsk demod no manchester decoding no start bit finding just get binary from wave - //set defaults int idx=0; //something in graphbuffer? if (GraphTraceLen < 65) { @@ -1220,11 +1218,6 @@ int CmdFSKdemodIO(const char *Cmd) //print full AWID Prox ID and some bit format details if found int CmdFSKdemodAWID(const char *Cmd) { - - //int verbose=1; - //sscanf(Cmd, "%i", &verbose); - - //raw fsk demod no manchester decoding no start bit finding just get binary from wave uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0}; size_t size = getFromGraphBuf(BitStream); if (size==0) return 0; @@ -1423,7 +1416,6 @@ int CmdFSKdemodPyramid(const char *Cmd) uint32_t fc = 0; uint32_t cardnum = 0; uint32_t code1 = 0; - //uint32_t code2 = 0; if (fmtLen==26){ fc = bytebits_to_byte(BitStream+73, 8); cardnum = bytebits_to_byte(BitStream+81, 16); diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index eddeec56..c0166b3e 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -197,21 +197,13 @@ int CmdEM410xWrite(const char *Cmd) } // Check Clock - if (card == 1) - { - // Default: 64 - if (clock == 0) - clock = 64; - - // Allowed clock rates: 16, 32 and 64 - if ((clock != 16) && (clock != 32) && (clock != 64)) { - PrintAndLog("Error! Clock rate %d not valid. Supported clock rates are 16, 32 and 64.\n", clock); - return 0; - } - } - else if (clock != 0) - { - PrintAndLog("Error! Clock rate is only supported on T55x7 tags.\n"); + // Default: 64 + if (clock == 0) + clock = 64; + + // Allowed clock rates: 16, 32, 40 and 64 + if ((clock != 16) && (clock != 32) && (clock != 64) && (clock != 40)) { + PrintAndLog("Error! Clock rate %d not valid. Supported clock rates are 16, 32, 40 and 64.\n", clock); return 0; } @@ -221,11 +213,11 @@ int CmdEM410xWrite(const char *Cmd) // provide for backwards-compatibility for older firmware, and to avoid // having to add another argument to CMD_EM410X_WRITE_TAG, we just store // the clock rate in bits 8-15 of the card value - card = (card & 0xFF) | (((uint64_t)clock << 8) & 0xFF00); - } - else if (card == 0) + card = (card & 0xFF) | ((clock << 8) & 0xFF00); + } else if (card == 0) { PrintAndLog("Writing %s tag with UID 0x%010" PRIx64, "T5555", id, clock); - else { + card = (card & 0xFF) | ((clock << 8) & 0xFF00); + } else { PrintAndLog("Error! Bad card type selected.\n"); return 0; } diff --git a/common/protocols.h b/common/protocols.h index d3e5f5d7..d8daa8da 100644 --- a/common/protocols.h +++ b/common/protocols.h @@ -243,7 +243,7 @@ void getMemConfig(uint8_t mem_cfg, uint8_t chip_cfg, uint8_t *max_blk, uint8_t * #define T5555_PSK_RF_8 0x00000200 #define T5555_USE_PWD 0x00000400 #define T5555_USE_AOR 0x00000800 -#define T5555_BITRATE_SHIFT 12 +#define T5555_BITRATE_SHIFT 12 //(RF=2n+2) ie 64=2*0x1F+2 or n = (RF-2)/2 #define T5555_FAST_WRITE 0x00004000 #define T5555_PAGE_SELECT 0x00008000 -- 2.39.5