]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
Merge pull request #251 from marshmellow42/master
authorIceman <iceman@iuse.se>
Sun, 26 Mar 2017 12:35:42 +0000 (14:35 +0200)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2017 12:35:42 +0000 (14:35 +0200)
split fdx-b demod to its own file

CHANGELOG.md
client/Makefile
client/cmddata.c
client/cmdlf.c
client/cmdlffdx.c [new file with mode: 0644]
client/cmdlffdx.h [new file with mode: 0644]
common/lfdemod.c

index ef9c316c8354faba6f6f0c6bb996ebb1d4e3a9d7..7994c987f2302ecdcd3842933b35eb205076ac4c 100644 (file)
@@ -5,8 +5,11 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
 ## [unreleased][unreleased]
 
 ### Added
-- Added lf gproxii read - reads a gproxii tag from the antenna
-- Added lf indala read - reads an indala tag from the antenna
+- Added lf fdx sim (iceman)
+- Added lf fdx clone - clones an fdx-b animal tag to t55x7 or q5 (iceman)
+- Added lf fdx read - reads a fdx-b tag from the antenna (iceman)
+- Added lf gproxii read - reads a gproxii tag from the antenna (marshmellow)
+- Added lf indala read - reads an indala tag from the antenna (marshmellow)
 - Added lf visa2000 demod, read, clone, sim commands (iceman)
 - Added markers in the graph around found Sequence Terminator after askmandemod.
 - Added data mtrim <start> <stop> command to trim out samples between start and stop
@@ -47,6 +50,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
 - Added option c to 'hf list' (mark CRC bytes) (piwi)
 
 ### Changed
+- `data fdxdemod` has been moved to `lf fdx demod` (reads from graphbuffer)
 - `data askgproxiidemod has been moved to `lf gproxii demod` (reads from graphbuffer)
 - `lf indalaclone` has been moved to `lf indala clone`
 - `lf indalademod` has been moved to `lf indala altdemod` (reads from graphbuffer)
index 36d0c994c2c6588d8286686882c53af8ee3fceaf..d5bfb08668113971abe22bcc4084f3d9cedbbaa0 100644 (file)
@@ -93,6 +93,7 @@ CMDSRCS =     crapto1/crapto1.c\
                        cmdlfawid.c \
                        cmdlfcotag.c\
                        cmdlfem4x.c \
+                       cmdlffdx.c \
                        cmdlfgproxii.c \
                        cmdlfhid.c \
                        cmdlfhitag.c \
index 1acce2edd4bc445e817cb597c2903b8607fd6e60..2444fb32ba3f6b113f0afff7828bbb81b9e2b193 100644 (file)
@@ -850,98 +850,6 @@ int CmdFSKdemodParadox(const char *Cmd)
        return 1;
 }
 
-// FDX-B ISO11784/85 demod  (aka animal tag)  BIPHASE, inverted, rf/32,  with preamble of 00000000001 (128bits)
-// 8 databits + 1 parity (1)
-// CIITT 16 chksum
-// NATIONAL CODE, ICAR database
-// COUNTRY CODE (ISO3166) or http://cms.abvma.ca/uploads/ManufacturersISOsandCountryCodes.pdf
-// FLAG (animal/non-animal)
-/*
-38 IDbits   
-10 country code 
-1 extra app bit
-14 reserved bits
-1 animal bit
-16 ccitt CRC chksum over 64bit ID CODE.
-24 appli bits.
-
--- sample: 985121004515220  [ 37FF65B88EF94 ]
-*/
-int CmdFDXBdemodBI(const char *Cmd){
-
-       int invert = 1;
-       int clk = 32;           
-       int errCnt = 0;
-       int maxErr = 0;
-       uint8_t BitStream[MAX_DEMOD_BUF_LEN];   
-       size_t size = getFromGraphBuf(BitStream);       
-       
-       errCnt = askdemod(BitStream, &size, &clk, &invert, maxErr, 0, 0);
-       if ( errCnt < 0 || errCnt > maxErr ) { 
-               if (g_debugMode) PrintAndLog("DEBUG: no data or error found %d, clock: %d", errCnt, clk);
-               return 0;
-       }
-
-       errCnt = BiphaseRawDecode(BitStream, &size, maxErr, 1);
-       if (errCnt < 0 || errCnt > maxErr ) {
-               if (g_debugMode) PrintAndLog("Error BiphaseRawDecode: %d", errCnt);
-               return 0;
-       } 
-
-       int preambleIndex = FDXBdemodBI(BitStream, &size);
-       if (preambleIndex < 0){
-               if (g_debugMode) PrintAndLog("Error FDXBDemod , no startmarker found :: %d",preambleIndex);
-               return 0;
-       }
-       if (size != 128) {
-               if (g_debugMode) PrintAndLog("Error incorrect data length found");
-               return 0;
-       }
-
-       setDemodBuf(BitStream, 128, preambleIndex);
-
-       // remove marker bits (1's every 9th digit after preamble) (pType = 2)
-       size = removeParity(BitStream, preambleIndex + 11, 9, 2, 117);
-       if ( size != 104 ) {
-               if (g_debugMode) PrintAndLog("Error removeParity:: %d", size);
-               return 0;
-       }
-       if (g_debugMode) {
-               char *bin = sprint_bin_break(BitStream,size,16);
-               PrintAndLog("DEBUG BinStream:\n%s",bin);
-       }
-       PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found:");
-       if (g_debugMode) PrintAndLog("Start marker %d;   Size %d", preambleIndex, size);
-
-       //got a good demod
-       uint64_t NationalCode = ((uint64_t)(bytebits_to_byteLSBF(BitStream+32,6)) << 32) | bytebits_to_byteLSBF(BitStream,32);
-       uint32_t countryCode = bytebits_to_byteLSBF(BitStream+38,10);
-       uint8_t dataBlockBit = BitStream[48];
-       uint32_t reservedCode = bytebits_to_byteLSBF(BitStream+49,14);
-       uint8_t animalBit = BitStream[63];
-       uint32_t crc16 = bytebits_to_byteLSBF(BitStream+64,16);
-       uint32_t extended = bytebits_to_byteLSBF(BitStream+80,24);
-
-       uint64_t rawid = ((uint64_t)bytebits_to_byte(BitStream,32)<<32) | bytebits_to_byte(BitStream+32,32);
-       uint8_t raw[8];
-       num_to_bytes(rawid, 8, raw);
-
-       if (g_debugMode) PrintAndLog("Raw ID Hex: %s", sprint_hex(raw,8));
-
-       uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
-       PrintAndLog("Animal ID:     %04u-%012" PRIu64, countryCode, NationalCode);
-       PrintAndLog("National Code: %012" PRIu64, NationalCode);
-       PrintAndLog("CountryCode:   %04u", countryCode);
-       PrintAndLog("Extended Data: %s", dataBlockBit ? "True" : "False");
-       PrintAndLog("reserved Code: %u", reservedCode);
-       PrintAndLog("Animal Tag:    %s", animalBit ? "True" : "False");
-       PrintAndLog("CRC:           0x%04X - [%04X] - %s", crc16, calcCrc, (calcCrc == crc16) ? "Passed" : "Failed");
-       PrintAndLog("Extended:      0x%X\n", extended);
-       
-       return 1;
-}
-
-
 //by marshmellow
 //attempt to psk1 demod graph buffer
 int PSKDemod(const char *Cmd, bool verbose)
@@ -1717,7 +1625,6 @@ static command_t CommandTable[] =
        {"buffclear",       CmdBuffClear,       1, "Clear sample buffer and graph window"},
        {"dec",             CmdDec,             1, "Decimate samples"},
        {"detectclock",     CmdDetectClockRate, 1, "[modulation] Detect clock rate of wave in GraphBuffer (options: 'a','f','n','p' for ask, fsk, nrz, psk respectively)"},
-       {"fdxbdemod",       CmdFDXBdemodBI    , 1, "Demodulate a FDX-B ISO11784/85 Biphase tag from GraphBuffer"},
        //{"fskfcdetect",   CmdFSKfcDetect,     1, "Try to detect the Field Clock of an FSK wave"},
        {"fskparadoxdemod", CmdFSKdemodParadox, 1, "Demodulate a Paradox FSK tag from GraphBuffer"},
        {"getbitstream",    CmdGetBitStream,    1, "Convert GraphBuffer's >=1 values to 1 and <1 to 0"},
index 10a70d7cee606523355af1ebf783a1e3084be924..9743749d2f51e827da2f2862223ca9226ffab234 100644 (file)
@@ -37,6 +37,7 @@
 #include "cmdlfvisa2000.h"  // for VISA2000 menu
 #include "cmdlfindala.h" // for indala menu
 #include "cmdlfgproxii.h"// for gproxii menu
+#include "cmdlffdx.h"    // for fdx-b menu
 
 bool g_lf_threshold_set = false;
 static int CmdHelp(const char *Cmd);
@@ -974,7 +975,7 @@ int CmdLFfind(const char *Cmd)
                return CheckChipType(cmdp);
        }
 
-       ans=CmdFDXBdemodBI("");
+       ans=CmdFdxDemod("");
        if (ans>0) {
                PrintAndLog("\nValid FDX-B ID Found!");
                return CheckChipType(cmdp);
@@ -1044,6 +1045,7 @@ static command_t CommandTable[] =
        {"awid",        CmdLFAWID,          1, "{ AWID RFIDs...    }"},
        {"cotag",       CmdLFCOTAG,         1, "{ COTAG RFIDs...   }"},
        {"em",          CmdLFEM4X,          1, "{ EM4X RFIDs...    }"},
+       {"fdx",         CmdLFFdx,           1, "{ FDX-B tags...    }"},
        {"gproxii",     CmdLF_G_Prox_II,    1, "{ G Prox II tags...    }"},
        {"hid",         CmdLFHID,           1, "{ HID RFIDs...     }"},
        {"hitag",       CmdLFHitag,         1, "{ Hitag tags and transponders... }"},
diff --git a/client/cmdlffdx.c b/client/cmdlffdx.c
new file mode 100644 (file)
index 0000000..69c3c48
--- /dev/null
@@ -0,0 +1,316 @@
+//-----------------------------------------------------------------------------
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency fdx-b tag commands
+//-----------------------------------------------------------------------------
+
+#include "cmdlffdx.h"
+
+#include <inttypes.h>
+#include "proxmark3.h"
+#include "ui.h"         // for PrintAndLog
+#include "util.h"
+#include "cmdparser.h"
+#include "cmddata.h"
+#include "cmdmain.h"
+#include "cmdlf.h"
+#include "crc16.h"
+#include "protocols.h"
+#include "lfdemod.h"
+
+/*
+       FDX-B ISO11784/85 demod  (aka animal tag)  BIPHASE, inverted, rf/32,  with preamble of 00000000001 (128bits)
+       8 databits + 1 parity (1)
+       CIITT 16 checksum
+       NATIONAL CODE, ICAR database
+       COUNTRY CODE (ISO3166) or http://cms.abvma.ca/uploads/ManufacturersISOsandCountryCodes.pdf
+       FLAG (animal/non-animal)
+
+       38 IDbits   
+       10 country code 
+       1 extra app bit
+       14 reserved bits
+       1 animal bit
+       16 ccitt CRC chksum over 64bit ID CODE.
+       24 appli bits.
+
+       sample: 985121004515220  [ 37FF65B88EF94 ]
+*/
+
+static int CmdHelp(const char *Cmd);
+
+int usage_lf_fdx_clone(void){
+       PrintAndLog("Clone a FDX-B animal tag to a T55x7 tag.");
+       PrintAndLog("Usage: lf animal clone [h] <country id> <animal id> <Q5>");
+       PrintAndLog("Options:");
+       PrintAndLog("      h            : This help");
+       PrintAndLog("      <country id> : Country id");
+       PrintAndLog("      <animal id>  : Animal id");
+       // has extended data?
+       //reserved/rfu
+       //is animal tag
+       // extended data
+       PrintAndLog("      <Q5>        : Specify write to Q5 (t5555 instead of t55x7)");
+       PrintAndLog("");
+       PrintAndLog("Sample: lf animal clone 999 112233");
+       return 0;
+}
+
+int usage_lf_fdx_sim(void) {
+       PrintAndLog("Enables simulation of FDX-B animal tag");
+       PrintAndLog("Simulation runs until the button is pressed or another USB command is issued.");
+       PrintAndLog("");
+       PrintAndLog("Usage:  lf animal sim [h] <country id> <animal id>");
+       PrintAndLog("Options:");
+       PrintAndLog("      h            : This help");
+       PrintAndLog("      <country id> : Country ID");
+       PrintAndLog("      <animal id>  : Animal ID");
+       PrintAndLog("");
+       PrintAndLog("Sample: lf animal sim 999 112233");
+       return 0;
+}
+// clearing the topbit needed for the preambl detection. 
+static void verify_values(uint32_t countryid, uint64_t animalid){
+       if ((animalid & 0x3FFFFFFFFF) != animalid) {
+               animalid &= 0x3FFFFFFFFF;
+               PrintAndLog("Animal ID Truncated to 38bits: %"PRIx64, animalid);
+       }       
+       if ( (countryid & 0x3ff) != countryid ) {
+               countryid &= 0x3ff;
+               PrintAndLog("Country ID Truncated to 10bits: %03d", countryid);
+       }
+}
+
+int getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) {
+
+       // 128bits
+       // every 9th bit is 0x01, but we can just fill the rest with 0x01 and overwrite
+       memset(bits, 0x01, 128);
+
+       // add preamble ten 0x00 and one 0x01
+       memset(bits, 0x00, 10);
+
+       // add reserved 
+       num_to_bytebitsLSBF(0x00, 7, bits + 66);
+       num_to_bytebitsLSBF(0x00 >> 7, 7, bits + 74);
+
+       // add animal flag - OK
+       bits[65] = isanimal;
+
+       // add extended flag - OK
+       bits[81] = isextended;
+
+       // add national code 40bits - OK
+       num_to_bytebitsLSBF(national_id >> 0, 8, bits+11);
+       num_to_bytebitsLSBF(national_id >> 8, 8, bits+20);
+       num_to_bytebitsLSBF(national_id >> 16, 8, bits+29);
+       num_to_bytebitsLSBF(national_id >> 24, 8, bits+38);
+       num_to_bytebitsLSBF(national_id >> 32, 6, bits+47);
+
+       // add country code - OK
+       num_to_bytebitsLSBF(country >> 0, 2, bits+53);
+       num_to_bytebitsLSBF(country >> 2, 8, bits+56);
+
+       // add crc-16 - OK
+       uint8_t raw[8];
+       for (uint8_t i=0; i<8; ++i)
+               raw[i] = bytebits_to_byte(bits + 11 + i * 9, 8);
+
+       uint16_t crc = crc16_ccitt_kermit(raw, 8);
+       num_to_bytebitsLSBF(crc >> 0, 8, bits+83);
+       num_to_bytebitsLSBF(crc >> 8, 8, bits+92);
+
+       // extended data - OK
+       num_to_bytebitsLSBF( extended >> 0 , 8, bits+101);
+       num_to_bytebitsLSBF( extended >> 8 , 8, bits+110);
+       num_to_bytebitsLSBF( extended >> 16, 8, bits+119);
+       return 1;
+}
+
+int CmdFdxDemod(const char *Cmd){
+
+       //Differential Biphase / di-phase (inverted biphase)
+       //get binary from ask wave
+       if (!ASKbiphaseDemod("0 32 1 0", FALSE)) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error - FDX-B ASKbiphaseDemod failed");
+               return 0;
+       }
+       size_t size = DemodBufferLen;
+       int preambleIndex = FDXBdemodBI(DemodBuffer, &size);
+       if (preambleIndex < 0){
+               if (g_debugMode){
+                       if (preambleIndex == -1)
+                               PrintAndLog("DEBUG: Error - FDX-B too few bits found");
+                       else if (preambleIndex == -2)
+                               PrintAndLog("DEBUG: Error - FDX-B preamble not found");
+                       else if (preambleIndex == -3)
+                               PrintAndLog("DEBUG: Error - FDX-B Size not correct: %d", size);
+                       else
+                               PrintAndLog("DEBUG: Error - FDX-B ans: %d", preambleIndex);
+               }
+               return 0;
+       }
+
+       // set and leave DemodBuffer intact
+       setDemodBuf(DemodBuffer, 128, preambleIndex);
+       uint8_t bits_no_spacer[117];
+       memcpy(bits_no_spacer, DemodBuffer + 11, 117);
+
+       // remove marker bits (1's every 9th digit after preamble) (pType = 2)
+       size = removeParity(bits_no_spacer, 0, 9, 2, 117);
+       if ( size != 104 ) {
+               if (g_debugMode) PrintAndLog("DEBUG: Error removeParity:: %d", size);
+               return 0;
+       }
+
+       //got a good demod
+       uint64_t NationalCode = ((uint64_t)(bytebits_to_byteLSBF(bits_no_spacer+32,6)) << 32) | bytebits_to_byteLSBF(bits_no_spacer,32);
+       uint32_t countryCode = bytebits_to_byteLSBF(bits_no_spacer+38,10);
+       uint8_t dataBlockBit = bits_no_spacer[48];
+       uint32_t reservedCode = bytebits_to_byteLSBF(bits_no_spacer+49,14);
+       uint8_t animalBit = bits_no_spacer[63];
+       uint32_t crc16 = bytebits_to_byteLSBF(bits_no_spacer+64,16);
+       uint32_t extended = bytebits_to_byteLSBF(bits_no_spacer+80,24);
+
+       uint64_t rawid = ((uint64_t)bytebits_to_byte(bits_no_spacer,32)<<32) | bytebits_to_byte(bits_no_spacer+32,32);
+       uint8_t raw[8];
+       num_to_bytes(rawid, 8, raw);
+
+       if (g_debugMode) {
+               PrintAndLog("DEBUG: bits_no_spacer:\n%s",sprint_bin_break(bits_no_spacer,size,16));
+               PrintAndLog("DEBUG: Start marker %d;   Size %d", preambleIndex, size);
+               PrintAndLog("DEBUG: Raw ID Hex: %s", sprint_hex(raw,8));
+       }
+
+       uint16_t calcCrc = crc16_ccitt_kermit(raw, 8);
+       PrintAndLog("\nFDX-B / ISO 11784/5 Animal Tag ID Found:");
+       PrintAndLog("Animal ID:     %04u-%012" PRIu64, countryCode, NationalCode);
+       PrintAndLog("National Code: %012" PRIu64, NationalCode);
+       PrintAndLog("CountryCode:   %04u", countryCode);
+       PrintAndLog("Reserved Code: %u", reservedCode);
+       PrintAndLog("Animal Tag:    %s", animalBit ? "True" : "False");
+       PrintAndLog("Has Extended:  %s [0x%X]", dataBlockBit ? "True" : "False", extended);
+       PrintAndLog("CRC:           0x%04X - 0x%04X - [%s]\n", crc16, calcCrc, (calcCrc == crc16) ? "Passed" : "Failed");
+       
+       // set block 0 for later
+       //g_DemodConfig = T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT;
+       return 1;
+}
+
+int CmdFdxRead(const char *Cmd) {
+       CmdLFRead("s");
+       getSamples("10000", TRUE);
+       return CmdFdxDemod(Cmd);
+}
+
+int CmdFdxClone(const char *Cmd) {
+
+       uint32_t countryid = 0;
+       uint64_t animalid = 0;
+       uint32_t blocks[5] = {T55x7_MODULATION_DIPHASE | T55x7_BITRATE_RF_32 | 4 << T55x7_MAXBLOCK_SHIFT, 0, 0, 0, 0};
+       uint8_t bits[128];
+       uint8_t *bs = bits;
+       memset(bs, 0, sizeof(bits));
+       
+       char cmdp = param_getchar(Cmd, 0);
+       if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_clone();
+
+       countryid = param_get32ex(Cmd, 0, 0, 10);
+       animalid = param_get64ex(Cmd, 1, 0, 10);
+       
+       //Q5
+       if (param_getchar(Cmd, 2) == 'Q' || param_getchar(Cmd, 2) == 'q') {
+               //t5555 (Q5) BITRATE = (RF-2)/2 (iceman)
+               blocks[0] = T5555_MODULATION_BIPHASE | T5555_INVERT_OUTPUT | ((32-2)>>1) << T5555_BITRATE_SHIFT | 4 << T5555_MAXBLOCK_SHIFT;
+       }
+       
+       verify_values(countryid, animalid);
+       
+       // getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) 
+       if ( !getFDXBits(animalid, countryid, 1, 0, 0, bs)) {
+               PrintAndLog("Error with tag bitstream generation.");
+               return 1;
+       }       
+       
+       // convert from bit stream to block data
+       blocks[1] = bytebits_to_byte(bs,32);
+       blocks[2] = bytebits_to_byte(bs+32,32);
+       blocks[3] = bytebits_to_byte(bs+64,32);
+       blocks[4] = bytebits_to_byte(bs+96,32);
+
+       PrintAndLog("Preparing to clone FDX-B to T55x7 with animal ID: %04u-%"PRIu64, countryid, animalid);
+       PrintAndLog("Blk | Data ");
+       PrintAndLog("----+------------");
+       PrintAndLog(" 00 | 0x%08x", blocks[0]);
+       PrintAndLog(" 01 | 0x%08x", blocks[1]);
+       PrintAndLog(" 02 | 0x%08x", blocks[2]);
+       PrintAndLog(" 03 | 0x%08x", blocks[3]);
+       PrintAndLog(" 04 | 0x%08x", blocks[4]);
+       
+       UsbCommand resp;
+       UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {0,0,0}};
+
+       for (int i = 4; i >= 0; --i) {
+               c.arg[0] = blocks[i];
+               c.arg[1] = i;
+               clearCommandBuffer();
+               SendCommand(&c);
+               if (!WaitForResponseTimeout(CMD_ACK, &resp, T55XX_WRITE_TIMEOUT)){
+                       PrintAndLog("Error occurred, device did not respond during write operation.");
+                       return -1;
+               }
+       }
+       return 0;
+}
+
+int CmdFdxSim(const char *Cmd) {
+       uint32_t countryid = 0;
+       uint64_t animalid = 0;
+
+       char cmdp = param_getchar(Cmd, 0);
+       if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_fdx_sim();
+
+       countryid = param_get32ex(Cmd, 0, 0, 10);
+       animalid = param_get64ex(Cmd, 1, 0, 10);
+       
+       verify_values(countryid, animalid);
+
+       uint8_t clk = 32, encoding = 2, separator = 0, invert = 1;
+       uint16_t arg1, arg2;
+       size_t size = 128;
+       arg1 = clk << 8 | encoding;
+       arg2 = invert << 8 | separator;
+
+       PrintAndLog("Simulating FDX-B animal ID: %04u-%"PRIu64, countryid, animalid);
+
+       UsbCommand c = {CMD_ASK_SIM_TAG, {arg1, arg2, size}};
+
+        //getFDXBits(uint64_t national_id, uint16_t country, uint8_t isanimal, uint8_t isextended, uint32_t extended, uint8_t *bits) 
+       getFDXBits(animalid, countryid, 1, 0, 0, c.d.asBytes);
+       clearCommandBuffer();
+       SendCommand(&c);
+       return 0;
+}
+
+static command_t CommandTable[] = {
+       {"help",  CmdHelp,    1, "This help"},
+       {"demod", CmdFdxDemod,1, "Attempt to extract FDX-B ISO11784/85 data from the GraphBuffer"},
+       {"read",  CmdFdxRead, 0, "Attempt to read and extract FDX-B ISO11784/85 data"},
+       {"clone", CmdFdxClone,0, "Clone animal ID tag to T55x7 (or to q5/T5555)"},
+       {"sim",   CmdFdxSim,  0, "Animal ID tag simulator"},
+       {NULL, NULL, 0, NULL}
+};
+
+int CmdLFFdx(const char *Cmd) {
+       clearCommandBuffer();
+       CmdsParse(CommandTable, Cmd);
+       return 0;
+}
+
+int CmdHelp(const char *Cmd) {
+       CmdsHelp(CommandTable);
+       return 0;
+}
diff --git a/client/cmdlffdx.h b/client/cmdlffdx.h
new file mode 100644 (file)
index 0000000..d11daec
--- /dev/null
@@ -0,0 +1,17 @@
+//-----------------------------------------------------------------------------
+//
+// This code is licensed to you under the terms of the GNU GPL, version 2 or,
+// at your option, any later version. See the LICENSE.txt file for the text of
+// the license.
+//-----------------------------------------------------------------------------
+// Low frequency fdx-b tag commands
+//-----------------------------------------------------------------------------
+#ifndef CMDLFFDX_H__
+#define CMDLFFDX_H__
+
+extern int CmdLFFdx(const char *Cmd);
+extern int CmdFdxClone(const char *Cmd);
+extern int CmdFdxSim(const char *Cmd);
+extern int CmdFdxRead(const char *Cmd);
+extern int CmdFdxDemod(const char *Cmd);
+#endif
index 8307a89088f57c5e468665c602dea7effcc0e984..eb84203e040b0f83f3d6b162dcadc0562aa13f24 100644 (file)
@@ -1703,6 +1703,8 @@ int FDXBdemodBI(uint8_t *dest, size_t *size) {
 
        uint8_t errChk = preambleSearch(dest, preamble, sizeof(preamble), size, &startIdx);
        if (errChk == 0) return -2; //preamble not found
+       if (*size != 128) return -3; //wrong size for fdxb
+       //return start position
        return (int)startIdx;
 }
 
Impressum, Datenschutz