mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-21 05:43:23 -07:00
Merge branch 'master' into topaz
Conflicts: armsrc/Makefile client/Makefile
This commit is contained in:
commit
6306ff4bac
31 changed files with 6975 additions and 5480 deletions
|
@ -66,6 +66,7 @@ CMDSRCS = nonce2key/crapto1.c\
|
|||
loclass/elite_crack.c\
|
||||
loclass/fileutils.c\
|
||||
mifarehost.c\
|
||||
crc.c \
|
||||
crc16.c \
|
||||
iso14443crc.c \
|
||||
iso15693tools.c \
|
||||
|
@ -100,8 +101,7 @@ CMDSRCS = nonce2key/crapto1.c\
|
|||
cmdscript.c\
|
||||
pm3_bitlib.c\
|
||||
aes.c\
|
||||
protocols.c\
|
||||
|
||||
protocols.c
|
||||
|
||||
COREOBJS = $(CORESRCS:%.c=$(OBJDIR)/%.o)
|
||||
CMDOBJS = $(CMDSRCS:%.c=$(OBJDIR)/%.o)
|
||||
|
|
3765
client/cmddata.c
3765
client/cmddata.c
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@ int CmdAskEM410xDemod(const char *Cmd);
|
|||
int CmdG_Prox_II_Demod(const char *Cmd);
|
||||
int Cmdaskrawdemod(const char *Cmd);
|
||||
int Cmdaskmandemod(const char *Cmd);
|
||||
int AutoCorrelate(int window, bool SaveGrph, bool verbose);
|
||||
int CmdAutoCorr(const char *Cmd);
|
||||
int CmdBiphaseDecodeRaw(const char *Cmd);
|
||||
int CmdBitsamples(const char *Cmd);
|
||||
|
@ -62,11 +63,16 @@ int CmdThreshold(const char *Cmd);
|
|||
int CmdDirectionalThreshold(const char *Cmd);
|
||||
int CmdZerocrossings(const char *Cmd);
|
||||
int CmdIndalaDecode(const char *Cmd);
|
||||
int AskEm410xDemod(const char *Cmd, uint32_t *hi, uint64_t *lo);
|
||||
int ASKbiphaseDemod(const char *Cmd, bool verbose);
|
||||
int ASKmanDemod(const char *Cmd, bool verbose, bool emSearch);
|
||||
int ASKrawDemod(const char *Cmd, bool verbose);
|
||||
int FSKrawDemod(const char *Cmd, bool verbose);
|
||||
int PSKDemod(const char *Cmd, bool verbose);
|
||||
int NRZrawDemod(const char *Cmd, bool verbose);
|
||||
void printEM410x(uint32_t hi, uint64_t id);
|
||||
int getSamples(const char *Cmd, bool silent);
|
||||
|
||||
|
||||
#define MAX_DEMOD_BUF_LEN (1024*128)
|
||||
extern uint8_t DemodBuffer[MAX_DEMOD_BUF_LEN];
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "loclass/elite_crack.h"
|
||||
#include "loclass/fileutils.h"
|
||||
#include "protocols.h"
|
||||
#include "usb_cmd.h"
|
||||
|
||||
static int CmdHelp(const char *Cmd);
|
||||
|
||||
|
@ -166,29 +167,25 @@ int CmdHFiClassSim(const char *Cmd)
|
|||
|
||||
int CmdHFiClassReader(const char *Cmd)
|
||||
{
|
||||
UsbCommand c = {CMD_READER_ICLASS, {0}};
|
||||
UsbCommand c = {CMD_READER_ICLASS, {FLAG_ICLASS_READER_CSN|
|
||||
FLAG_ICLASS_READER_CONF|FLAG_ICLASS_READER_AA}};
|
||||
SendCommand(&c);
|
||||
UsbCommand resp;
|
||||
while(!ukbhit()){
|
||||
if (WaitForResponseTimeout(CMD_ACK,&resp,4500)) {
|
||||
uint8_t isOK = resp.arg[0] & 0xff;
|
||||
uint8_t readStatus = resp.arg[0] & 0xff;
|
||||
uint8_t * data = resp.d.asBytes;
|
||||
|
||||
PrintAndLog("isOk:%02x", isOK);
|
||||
if( isOK == 0){
|
||||
PrintAndLog("Readstatus:%02x", readStatus);
|
||||
if( readStatus == 0){
|
||||
//Aborted
|
||||
PrintAndLog("Quitting...");
|
||||
return 0;
|
||||
}
|
||||
if(isOK > 0)
|
||||
{
|
||||
PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
}
|
||||
if(isOK >= 1)
|
||||
{
|
||||
PrintAndLog("CC: %s",sprint_hex(data+8,8));
|
||||
}else{
|
||||
PrintAndLog("No CC obtained");
|
||||
if( readStatus & FLAG_ICLASS_READER_CSN) PrintAndLog("CSN: %s",sprint_hex(data,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CC) PrintAndLog("CC: %s",sprint_hex(data+16,8));
|
||||
if( readStatus & FLAG_ICLASS_READER_CONF){
|
||||
printIclassDumpInfo(data);
|
||||
}
|
||||
} else {
|
||||
PrintAndLog("Command execute timeout");
|
||||
|
@ -269,7 +266,7 @@ int CmdHFiClassReader_Dump(const char *Cmd)
|
|||
uint8_t key_sel_p[8] = { 0 };
|
||||
|
||||
UsbCommand c = {CMD_READER_ICLASS, {0}};
|
||||
c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE| FLAG_ICLASS_READER_GET_CC;
|
||||
c.arg[0] = FLAG_ICLASS_READER_ONLY_ONCE| FLAG_ICLASS_READER_CC;
|
||||
SendCommand(&c);
|
||||
|
||||
|
||||
|
@ -284,7 +281,7 @@ int CmdHFiClassReader_Dump(const char *Cmd)
|
|||
uint8_t * data = resp.d.asBytes;
|
||||
|
||||
memcpy(CSN,data,8);
|
||||
memcpy(CCNR,data+8,8);
|
||||
memcpy(CCNR,data+16,8);
|
||||
|
||||
PrintAndLog("isOk:%02x", isOK);
|
||||
|
||||
|
|
|
@ -1539,7 +1539,7 @@ int CmdHF14AMfCLoad(const char *Cmd)
|
|||
char buf[64] = {0x00};
|
||||
uint8_t buf8[64] = {0x00};
|
||||
uint8_t fillFromEmulator = 0;
|
||||
int i, len, blockNum, flags;
|
||||
int i, len, blockNum, flags=0;
|
||||
|
||||
if (param_getchar(Cmd, 0) == 'h' || param_getchar(Cmd, 0)== 0x00) {
|
||||
PrintAndLog("It loads magic Chinese card from the file `filename.eml`");
|
||||
|
|
|
@ -320,7 +320,7 @@ int CmdHFTopazReader(const char *Cmd)
|
|||
for (uint16_t j = 0; j < 8; j++) {
|
||||
sprintf(&line[3*j], "%02x ", topaz_tag.data_blocks[i][j] /*rall_response[2 + 8*i + j]*/);
|
||||
}
|
||||
PrintAndLog(" 0x%02x | 0x%02x | %s| %-3s", i, i*8, line, topaz_block_is_locked(i, &topaz_tag.data_blocks[0x0d][0]) ? "yes" : "no");
|
||||
PrintAndLog(" 0x%02x | 0x%02x | %s| %-3s", i, i*8, line, topaz_block_is_locked(i, &topaz_tag.data_blocks[0x0e][0]) ? "yes" : "no");
|
||||
}
|
||||
|
||||
PrintAndLog("");
|
||||
|
|
1612
client/cmdlf.c
1612
client/cmdlf.c
File diff suppressed because it is too large
Load diff
|
@ -43,163 +43,24 @@ int CmdEMdemodASK(const char *Cmd)
|
|||
*/
|
||||
int CmdEM410xRead(const char *Cmd)
|
||||
{
|
||||
int i, j, clock, header, rows, bit, hithigh, hitlow, first, bit2idx, high, low;
|
||||
int parity[4];
|
||||
char id[11] = {0x00};
|
||||
char id2[11] = {0x00};
|
||||
int retested = 0;
|
||||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN];
|
||||
high = low = 0;
|
||||
uint32_t hi=0;
|
||||
uint64_t lo=0;
|
||||
|
||||
/* Detect high and lows and clock */
|
||||
for (i = 0; i < GraphTraceLen; i++)
|
||||
{
|
||||
if (GraphBuffer[i] > high)
|
||||
high = GraphBuffer[i];
|
||||
else if (GraphBuffer[i] < low)
|
||||
low = GraphBuffer[i];
|
||||
}
|
||||
|
||||
/* get clock */
|
||||
clock = GetAskClock(Cmd, false, false);
|
||||
|
||||
/* parity for our 4 columns */
|
||||
parity[0] = parity[1] = parity[2] = parity[3] = 0;
|
||||
header = rows = 0;
|
||||
|
||||
// manchester demodulate
|
||||
bit = bit2idx = 0;
|
||||
for (i = 0; i < (int)(GraphTraceLen / clock); i++)
|
||||
{
|
||||
hithigh = 0;
|
||||
hitlow = 0;
|
||||
first = 1;
|
||||
|
||||
/* Find out if we hit both high and low peaks */
|
||||
for (j = 0; j < clock; j++)
|
||||
{
|
||||
if (GraphBuffer[(i * clock) + j] >= high)
|
||||
hithigh = 1;
|
||||
else if (GraphBuffer[(i * clock) + j] <= low)
|
||||
hitlow = 1;
|
||||
|
||||
/* it doesn't count if it's the first part of our read
|
||||
because it's really just trailing from the last sequence */
|
||||
if (first && (hithigh || hitlow))
|
||||
hithigh = hitlow = 0;
|
||||
else
|
||||
first = 0;
|
||||
|
||||
if (hithigh && hitlow)
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we didn't hit both high and low peaks, we had a bit transition */
|
||||
if (!hithigh || !hitlow)
|
||||
bit ^= 1;
|
||||
|
||||
BitStream[bit2idx++] = bit;
|
||||
}
|
||||
|
||||
retest:
|
||||
/* We go till 5 before the graph ends because we'll get that far below */
|
||||
for (i = 1; i < bit2idx - 5; i++)
|
||||
{
|
||||
/* Step 2: We have our header but need our tag ID */
|
||||
if (header == 9 && rows < 10)
|
||||
{
|
||||
/* Confirm parity is correct */
|
||||
if ((BitStream[i] ^ BitStream[i+1] ^ BitStream[i+2] ^ BitStream[i+3]) == BitStream[i+4])
|
||||
{
|
||||
/* Read another byte! */
|
||||
sprintf(id+rows, "%x", (8 * BitStream[i]) + (4 * BitStream[i+1]) + (2 * BitStream[i+2]) + (1 * BitStream[i+3]));
|
||||
sprintf(id2+rows, "%x", (8 * BitStream[i+3]) + (4 * BitStream[i+2]) + (2 * BitStream[i+1]) + (1 * BitStream[i]));
|
||||
rows++;
|
||||
|
||||
/* Keep parity info */
|
||||
parity[0] ^= BitStream[i];
|
||||
parity[1] ^= BitStream[i+1];
|
||||
parity[2] ^= BitStream[i+2];
|
||||
parity[3] ^= BitStream[i+3];
|
||||
|
||||
/* Move 4 bits ahead */
|
||||
i += 4;
|
||||
}
|
||||
|
||||
/* Damn, something wrong! reset */
|
||||
else
|
||||
{
|
||||
PrintAndLog("Thought we had a valid tag but failed at word %d (i=%d)", rows + 1, i);
|
||||
|
||||
/* Start back rows * 5 + 9 header bits, -1 to not start at same place */
|
||||
i -= 9 + (5 * rows) - 5;
|
||||
|
||||
rows = header = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Step 3: Got our 40 bits! confirm column parity */
|
||||
else if (rows == 10)
|
||||
{
|
||||
/* We need to make sure our 4 bits of parity are correct and we have a stop bit */
|
||||
if (BitStream[i] == parity[0] && BitStream[i+1] == parity[1] &&
|
||||
BitStream[i+2] == parity[2] && BitStream[i+3] == parity[3] &&
|
||||
BitStream[i+4] == 0)
|
||||
{
|
||||
/* Sweet! */
|
||||
PrintAndLog("EM410x Tag ID: %s", id);
|
||||
PrintAndLog("Unique Tag ID: %s", id2);
|
||||
|
||||
global_em410xId = id;
|
||||
|
||||
/* Stop any loops */
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Crap! Incorrect parity or no stop bit, start all over */
|
||||
else
|
||||
{
|
||||
rows = header = 0;
|
||||
|
||||
/* Go back 59 bits (9 header bits + 10 rows at 4+1 parity) */
|
||||
i -= 59;
|
||||
}
|
||||
}
|
||||
|
||||
/* Step 1: get our header */
|
||||
else if (header < 9)
|
||||
{
|
||||
/* Need 9 consecutive 1's */
|
||||
if (BitStream[i] == 1)
|
||||
header++;
|
||||
|
||||
/* We don't have a header, not enough consecutive 1 bits */
|
||||
else
|
||||
header = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we've already retested after flipping bits, return */
|
||||
if (retested++){
|
||||
PrintAndLog("Failed to decode");
|
||||
if(!AskEm410xDemod("", &hi, &lo)) return 0;
|
||||
PrintAndLog("EM410x pattern found: ");
|
||||
printEM410x(hi, lo);
|
||||
if (hi){
|
||||
PrintAndLog ("EM410x XL pattern found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if this didn't work, try flipping bits */
|
||||
for (i = 0; i < bit2idx; i++)
|
||||
BitStream[i] ^= 1;
|
||||
|
||||
goto retest;
|
||||
}
|
||||
char id[12] = {0x00};
|
||||
sprintf(id, "%010llx",lo);
|
||||
|
||||
global_em410xId = id;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* emulate an EM410X tag
|
||||
* Format:
|
||||
* 1111 1111 1 <-- standard non-repeatable header
|
||||
* XXXX [row parity bit] <-- 10 rows of 5 bits for our 40 bit tag ID
|
||||
* ....
|
||||
* CCCC <-- each bit here is parity for the 10 bits above in corresponding column
|
||||
* 0 <-- stop bit, end of tag
|
||||
*/
|
||||
// emulate an EM410X tag
|
||||
int CmdEM410xSim(const char *Cmd)
|
||||
{
|
||||
int i, n, j, binary[4], parity[4];
|
||||
|
@ -282,28 +143,25 @@ int CmdEM410xSim(const char *Cmd)
|
|||
*/
|
||||
int CmdEM410xWatch(const char *Cmd)
|
||||
{
|
||||
char cmdp = param_getchar(Cmd, 0);
|
||||
int read_h = (cmdp == 'h');
|
||||
do {
|
||||
if (ukbhit()) {
|
||||
printf("\naborted via keyboard!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
CmdLFRead(read_h ? "h" : "");
|
||||
CmdSamples("6000");
|
||||
} while (
|
||||
!CmdEM410xRead("")
|
||||
);
|
||||
CmdLFRead("s");
|
||||
getSamples("8192",true); //capture enough to get 2 full messages
|
||||
} while (!CmdEM410xRead(""));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CmdEM410xWatchnSpoof(const char *Cmd)
|
||||
{
|
||||
CmdEM410xWatch(Cmd);
|
||||
PrintAndLog("# Replaying : %s",global_em410xId);
|
||||
CmdEM410xSim(global_em410xId);
|
||||
return 0;
|
||||
PrintAndLog("# Replaying captured ID: %s",global_em410xId);
|
||||
CmdLFaskSim("");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read the transmitted data of an EM4x50 tag
|
||||
|
|
1138
client/cmdlft55xx.c
1138
client/cmdlft55xx.c
File diff suppressed because it is too large
Load diff
|
@ -10,12 +10,57 @@
|
|||
#ifndef CMDLFT55XX_H__
|
||||
#define CMDLFT55XX_H__
|
||||
|
||||
int CmdLFT55XX(const char *Cmd);
|
||||
typedef struct {
|
||||
enum {
|
||||
DEMOD_NRZ = 0x00,
|
||||
DEMOD_PSK1 = 0x01,
|
||||
DEMOD_PSK2 = 0x02,
|
||||
DEMOD_PSK3 = 0x03,
|
||||
DEMOD_FSK1 = 0x04,
|
||||
DEMOD_FSK1a = 0x05,
|
||||
DEMOD_FSK2 = 0x06,
|
||||
DEMOD_FSK2a = 0x07,
|
||||
DEMOD_FSK = 0xF0, //generic FSK (auto detect FCs)
|
||||
DEMOD_ASK = 0x08,
|
||||
DEMOD_BI = 0x10,
|
||||
DEMOD_BIa = 0x18,
|
||||
} modulation;
|
||||
bool inverted;
|
||||
uint8_t offset;
|
||||
uint32_t block0;
|
||||
enum {
|
||||
RF_8 = 0x00,
|
||||
RF_16 = 0x01,
|
||||
RF_32 = 0x02,
|
||||
RF_40 = 0x03,
|
||||
RF_50 = 0x04,
|
||||
RF_64 = 0x05,
|
||||
RF_100 = 0x06,
|
||||
RF_128 = 0x07,
|
||||
} bitrate;
|
||||
} t55xx_conf_block_t;
|
||||
|
||||
int CmdReadBlk(const char *Cmd);
|
||||
int CmdReadBlkPWD(const char *Cmd);
|
||||
int CmdWriteBlk(const char *Cmd);
|
||||
int CmdWriteBLkPWD(const char *Cmd);
|
||||
int CmdReadTrace(const char *Cmd);
|
||||
int CmdLFT55XX(const char *Cmd);
|
||||
int CmdT55xxSetConfig(const char *Cmd);
|
||||
int CmdT55xxReadBlock(const char *Cmd);
|
||||
int CmdT55xxWriteBlock(const char *Cmd);
|
||||
int CmdT55xxReadTrace(const char *Cmd);
|
||||
int CmdT55xxInfo(const char *Cmd);
|
||||
int CmdT55xxDetect(const char *Cmd);
|
||||
|
||||
char * GetBitRateStr(uint32_t id);
|
||||
char * GetSaferStr(uint32_t id);
|
||||
char * GetModulationStr( uint32_t id);
|
||||
char * GetModelStrFromCID(uint32_t cid);
|
||||
char * GetSelectedModulationStr( uint8_t id);
|
||||
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream);
|
||||
void printT55xxBlock(const char *demodStr);
|
||||
void printConfiguration( t55xx_conf_block_t b);
|
||||
|
||||
bool DecodeT55xxBlock();
|
||||
bool tryDetectModulation();
|
||||
bool test(uint8_t mode, uint8_t *offset);
|
||||
int special(const char *Cmd);
|
||||
int AquireData( uint8_t block );
|
||||
|
||||
#endif
|
||||
|
|
|
@ -146,7 +146,7 @@ uint8_t GetPskCarrier(const char str[], bool printAns, bool verbose)
|
|||
}
|
||||
//uint8_t countPSK_FC(uint8_t *BitStream, size_t size)
|
||||
|
||||
carrier = countPSK_FC(grph,size);
|
||||
carrier = countFC(grph,size,0);
|
||||
// Only print this message if we're not looping something
|
||||
if (printAns){
|
||||
PrintAndLog("Auto-detected PSK carrier rate: %d", carrier);
|
||||
|
@ -232,8 +232,7 @@ uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose)
|
|||
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
|
||||
size_t size = getFromGraphBuf(BitStream);
|
||||
if (size==0) return 0;
|
||||
uint8_t dummy = 0;
|
||||
uint16_t ans = countFC(BitStream, size, &dummy);
|
||||
uint16_t ans = countFC(BitStream, size, 1);
|
||||
if (ans==0) {
|
||||
if (verbose) PrintAndLog("DEBUG: No data found");
|
||||
return 0;
|
||||
|
|
139
client/scripts/test_t55x7_ask.lua
Normal file
139
client/scripts/test_t55x7_ask.lua
Normal file
|
@ -0,0 +1,139 @@
|
|||
local cmds = require('commands')
|
||||
local getopt = require('getopt')
|
||||
local bin = require('bin')
|
||||
local utils = require('utils')
|
||||
|
||||
local format=string.format
|
||||
local floor=math.floor
|
||||
|
||||
example =[[
|
||||
1. script run test_t55x7_ask
|
||||
]]
|
||||
author = "Iceman"
|
||||
usage = "script run test_t55x7_ask"
|
||||
desc =[[
|
||||
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
|
||||
The outlined procedure is as following:
|
||||
|
||||
--ASK
|
||||
00 00 80 40
|
||||
-- max 2
|
||||
-- manchester
|
||||
-- bit rate
|
||||
|
||||
"lf t55xx write 0 00008040"
|
||||
"lf t55xx detect"
|
||||
"lf t55xx info"
|
||||
|
||||
Loop:
|
||||
change the configuretion block 0 with:
|
||||
-xx 00 xxxx = RF/8
|
||||
-xx 04 xxxx = RF/16
|
||||
-xx 08 xxxx = RF/32
|
||||
-xx 0C xxxx = RF/40
|
||||
-xx 10 xxxx = RF/50
|
||||
-xx 14 xxxx = RF/64
|
||||
-xx 18 xxxx = RF/100
|
||||
-xx 1C xxxx = RF/128
|
||||
|
||||
|
||||
testsuit for the ASK/MANCHESTER demod
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
]]
|
||||
|
||||
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||
local DEBUG = true -- the debug flag
|
||||
|
||||
--BLOCK 0 = 00008040 ASK / MAN
|
||||
local config1 = '00'
|
||||
local config2 = '8040'
|
||||
|
||||
local procedurecmds = {
|
||||
[1] = '%s%02X%s',
|
||||
[2] = 'lf t55xx detect',
|
||||
[3] = 'lf t55xx info',
|
||||
}
|
||||
---
|
||||
-- A debug printout-function
|
||||
function dbg(args)
|
||||
if not DEBUG then
|
||||
return
|
||||
end
|
||||
|
||||
if type(args) == "table" then
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print("###", args)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
function oops(err)
|
||||
print("ERROR: ",err)
|
||||
end
|
||||
---
|
||||
-- Usage help
|
||||
function help()
|
||||
print(desc)
|
||||
print("Example usage")
|
||||
print(example)
|
||||
end
|
||||
--
|
||||
-- Exit message
|
||||
function ExitMsg(msg)
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
print(msg)
|
||||
print()
|
||||
end
|
||||
|
||||
function test()
|
||||
local y
|
||||
for y = 0x0, 0x1d, 0x4 do
|
||||
for _ = 1, #procedurecmds do
|
||||
local pcmd = procedurecmds[_]
|
||||
|
||||
if #pcmd == 0 then
|
||||
|
||||
elseif _ == 1 then
|
||||
|
||||
local config = pcmd:format(config1, y, config2)
|
||||
dbg(('lf t55xx write 0 %s'):format(config))
|
||||
config = tonumber(config,16)
|
||||
|
||||
local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}
|
||||
local err = core.SendCommand(writecmd:getBytes())
|
||||
if err then return oops(err) end
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
||||
|
||||
else
|
||||
dbg(pcmd)
|
||||
core.console( pcmd )
|
||||
end
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
|
||||
local function main(args)
|
||||
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
|
||||
-- Arguments for the script
|
||||
for o, arg in getopt.getopt(args, 'h') do
|
||||
if o == "h" then return help() end
|
||||
end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
test()
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
main(args)
|
133
client/scripts/test_t55x7_bi.lua
Normal file
133
client/scripts/test_t55x7_bi.lua
Normal file
|
@ -0,0 +1,133 @@
|
|||
local cmds = require('commands')
|
||||
local getopt = require('getopt')
|
||||
local bin = require('bin')
|
||||
local utils = require('utils')
|
||||
|
||||
example =[[
|
||||
1. script run test_t55x7_bi
|
||||
]]
|
||||
author = "Iceman"
|
||||
usage = "script run test_t55x7_bi"
|
||||
desc =[[
|
||||
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00010040
|
||||
The outlined procedure is as following:
|
||||
|
||||
--BIPHASE 00010040
|
||||
--
|
||||
|
||||
"lf t55xx write 0 00010040"
|
||||
"lf t55xx detect"
|
||||
"lf t55xx info"
|
||||
|
||||
Loop:
|
||||
change the configuretion block 0 with:
|
||||
-xx01xxxx = RF/8
|
||||
-xx05xxxx = RF/16
|
||||
-xx09xxxx = RF/32
|
||||
-xx0Dxxxx = RF/40
|
||||
-xx11xxxx = RF/50
|
||||
-xx15xxxx = RF/64
|
||||
-xx19xxxx = RF/100
|
||||
-xx1Dxxxx = RF/128
|
||||
|
||||
|
||||
testsuit for the BIPHASE demod
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
]]
|
||||
|
||||
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||
local DEBUG = true -- the debug flag
|
||||
|
||||
--BLOCK 0 = 00010040 BIPHASE
|
||||
local config1 = '00'
|
||||
local config2 = '0040'
|
||||
|
||||
local procedurecmds = {
|
||||
[1] = '%s%02X%s',
|
||||
[2] = 'lf t55xx detect',
|
||||
[3] = 'lf t55xx info',
|
||||
}
|
||||
---
|
||||
-- A debug printout-function
|
||||
function dbg(args)
|
||||
if not DEBUG then
|
||||
return
|
||||
end
|
||||
|
||||
if type(args) == "table" then
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print("###", args)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
function oops(err)
|
||||
print("ERROR: ",err)
|
||||
end
|
||||
---
|
||||
-- Usage help
|
||||
function help()
|
||||
print(desc)
|
||||
print("Example usage")
|
||||
print(example)
|
||||
end
|
||||
--
|
||||
-- Exit message
|
||||
function ExitMsg(msg)
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
print(msg)
|
||||
print()
|
||||
end
|
||||
|
||||
function test()
|
||||
local y
|
||||
for y = 1, 0x1D, 4 do
|
||||
for _ = 1, #procedurecmds do
|
||||
local pcmd = procedurecmds[_]
|
||||
|
||||
if #pcmd == 0 then
|
||||
|
||||
elseif _ == 1 then
|
||||
|
||||
local config = pcmd:format(config1, y, config2)
|
||||
dbg(('lf t55xx wr 0 %s'):format(config))
|
||||
|
||||
config = tonumber(config,16)
|
||||
local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}
|
||||
local err = core.SendCommand(writecmd:getBytes())
|
||||
if err then return oops(err) end
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
||||
else
|
||||
dbg(pcmd)
|
||||
core.console( pcmd )
|
||||
end
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
print( string.rep('--',20) )
|
||||
|
||||
end
|
||||
|
||||
local function main(args)
|
||||
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
|
||||
-- Arguments for the script
|
||||
for o, arg in getopt.getopt(args, 'h') do
|
||||
if o == "h" then return help() end
|
||||
end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
test()
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
main(args)
|
139
client/scripts/test_t55x7_fsk.lua
Normal file
139
client/scripts/test_t55x7_fsk.lua
Normal file
|
@ -0,0 +1,139 @@
|
|||
local cmds = require('commands')
|
||||
local getopt = require('getopt')
|
||||
local bin = require('bin')
|
||||
local utils = require('utils')
|
||||
|
||||
example =[[
|
||||
1. script run test_t55x7_fsk
|
||||
]]
|
||||
author = "Iceman"
|
||||
usage = "script run test_t55x7_fsk"
|
||||
desc =[[
|
||||
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
|
||||
The outlined procedure is as following:
|
||||
|
||||
--ASK
|
||||
00 00 80 40
|
||||
-- max 2 blocks
|
||||
-- FSK1
|
||||
-- bit rate
|
||||
|
||||
"lf t55xx write 0 00007040"
|
||||
"lf t55xx detect"
|
||||
"lf t55xx info"
|
||||
|
||||
Loop:
|
||||
change the configuretion block 0 with:
|
||||
-xx 00 xxxx = RF/8
|
||||
-xx 04 xxxx = RF/16
|
||||
-xx 08 xxxx = RF/32
|
||||
-xx 0C xxxx = RF/40
|
||||
-xx 10 xxxx = RF/50
|
||||
-xx 14 xxxx = RF/64
|
||||
-xx 18 xxxx = RF/100
|
||||
-xx 1C xxxx = RF/128
|
||||
|
||||
|
||||
testsuit for the ASK/MANCHESTER demod
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
]]
|
||||
|
||||
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||
local DEBUG = true -- the debug flag
|
||||
|
||||
--BLOCK 0 = 00008040 FSK
|
||||
local config1 = '00'
|
||||
local config2 = '040'
|
||||
|
||||
local procedurecmds = {
|
||||
[1] = '%s%02X%X%s',
|
||||
[2] = 'lf t55xx detect',
|
||||
[3] = 'lf t55xx info',
|
||||
}
|
||||
---
|
||||
-- A debug printout-function
|
||||
function dbg(args)
|
||||
if not DEBUG then
|
||||
return
|
||||
end
|
||||
|
||||
if type(args) == "table" then
|
||||
local i = 1
|
||||
while args[i] do
|
||||
dbg(args[i])
|
||||
i = i+1
|
||||
end
|
||||
else
|
||||
print("###", args)
|
||||
end
|
||||
end
|
||||
---
|
||||
-- This is only meant to be used when errors occur
|
||||
function oops(err)
|
||||
print("ERROR: ",err)
|
||||
end
|
||||
---
|
||||
-- Usage help
|
||||
function help()
|
||||
print(desc)
|
||||
print("Example usage")
|
||||
print(example)
|
||||
end
|
||||
--
|
||||
-- Exit message
|
||||
function ExitMsg(msg)
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
print(msg)
|
||||
print()
|
||||
end
|
||||
|
||||
function test(modulation)
|
||||
local y
|
||||
for y = 0x0, 0x1d, 0x4 do
|
||||
for _ = 1, #procedurecmds do
|
||||
local pcmd = procedurecmds[_]
|
||||
|
||||
if #pcmd == 0 then
|
||||
|
||||
elseif _ == 1 then
|
||||
|
||||
local config = pcmd:format(config1, y, modulation, config2)
|
||||
dbg(('lf t55xx write 0 %s'):format(config))
|
||||
|
||||
config = tonumber(config,16)
|
||||
local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}
|
||||
local err = core.SendCommand(writecmd:getBytes())
|
||||
if err then return oops(err) end
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
||||
|
||||
else
|
||||
dbg(pcmd)
|
||||
core.console( pcmd )
|
||||
end
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
|
||||
local function main(args)
|
||||
|
||||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
|
||||
-- Arguments for the script
|
||||
for o, arg in getopt.getopt(args, 'h') do
|
||||
if o == "h" then return help() end
|
||||
end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
test(4)
|
||||
test(5)
|
||||
test(6)
|
||||
test(7)
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
main(args)
|
|
@ -2,15 +2,14 @@ local cmds = require('commands')
|
|||
local getopt = require('getopt')
|
||||
local bin = require('bin')
|
||||
local utils = require('utils')
|
||||
local dumplib = require('html_dumplib')
|
||||
|
||||
example =[[
|
||||
1. script run tracetest
|
||||
2. script run tracetest -o
|
||||
1. script run test_t55x7_psk
|
||||
2. script run test_t55x7_psk -o
|
||||
|
||||
]]
|
||||
author = "Iceman"
|
||||
usage = "script run test_t55x7_psk -o <filename>"
|
||||
usage = "script run test_t55x7_psk"
|
||||
desc =[[
|
||||
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
|
||||
The outlined procedure is as following:
|
||||
|
@ -39,26 +38,35 @@ In all 12 individual test for the PSK demod
|
|||
|
||||
Arguments:
|
||||
-h : this help
|
||||
-o : logfile name
|
||||
]]
|
||||
|
||||
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||
local DEBUG = true -- the debug flag
|
||||
|
||||
--BLOCK 0 = 00088040
|
||||
local config1 = '0008'
|
||||
local config2 = '40'
|
||||
|
||||
local procedurecmds = {
|
||||
[1] = '%s%s%s%s',
|
||||
[2] = 'lf read',
|
||||
--[3] = '',
|
||||
[3] = 'data samples',
|
||||
[4] = 'data pskdetectclock',
|
||||
[5] = 'data psknrzrawdemod',
|
||||
[6] = 'data pskindalademod',
|
||||
}
|
||||
-- local procedurecmds = {
|
||||
-- [1] = '%s%s%s%s',
|
||||
-- [2] = 'lf read',
|
||||
-- --[3] = '',
|
||||
-- [3] = 'data samples',
|
||||
-- [4] = 'data pskdetectclock',
|
||||
-- [5] = 'data psknrzrawdemod',
|
||||
-- [6] = 'data pskindalademod',
|
||||
-- }
|
||||
|
||||
-- --BLOCK 0 = 00 08 80 40 PSK
|
||||
-- -----------
|
||||
-- 08------- bitrate
|
||||
-- 8----- modulation PSK1
|
||||
-- 0---- PSK ClockRate
|
||||
-- 40 max 2 blocks
|
||||
|
||||
local procedurecmds = {
|
||||
[1] = '00%02X%X%X40',
|
||||
[2] = 'lf t55xx detect',
|
||||
--[3] = '',
|
||||
[3] = 'lf t55xx info',
|
||||
}
|
||||
---
|
||||
-- A debug printout-function
|
||||
function dbg(args)
|
||||
|
@ -97,45 +105,39 @@ function ExitMsg(msg)
|
|||
print()
|
||||
end
|
||||
|
||||
function pskTest(modulation)
|
||||
local y
|
||||
for y = 0, 8, 4 do
|
||||
for _ = 1, #procedurecmds do
|
||||
local cmd = procedurecmds[_]
|
||||
|
||||
if #cmd == 0 then
|
||||
|
||||
elseif _ == 1 then
|
||||
function test(modulation)
|
||||
local bitrate
|
||||
local clockrate
|
||||
for bitrate = 0x0, 0x1d, 0x4 do
|
||||
|
||||
for clockrate = 0,8,4 do
|
||||
|
||||
dbg("Writing to T55x7 TAG")
|
||||
|
||||
local configdata = cmd:format( config1, modulation , y, config2)
|
||||
for _ = 1, #procedurecmds do
|
||||
local cmd = procedurecmds[_]
|
||||
|
||||
dbg( configdata)
|
||||
if #cmd == 0 then
|
||||
|
||||
local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = configdata ,arg2 = 0, arg3 = 0}
|
||||
local err = core.SendCommand(writecommand:getBytes())
|
||||
if err then return oops(err) end
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
||||
elseif _ == 1 then
|
||||
|
||||
if response then
|
||||
local count,cmd,arg0 = bin.unpack('LL',response)
|
||||
if(arg0==1) then
|
||||
dbg("Writing success")
|
||||
else
|
||||
return nil, "Couldn't read block.."
|
||||
end
|
||||
dbg("Writing to T55x7 TAG")
|
||||
|
||||
local config = cmd:format(bitrate, modulation, clockrate)
|
||||
dbg(('lf t55xx write 0 %s'):format(config))
|
||||
|
||||
config = tonumber(config,16)
|
||||
local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
|
||||
local err = core.SendCommand(writecommand:getBytes())
|
||||
if err then return oops(err) end
|
||||
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
||||
else
|
||||
dbg(cmd)
|
||||
core.console( cmd )
|
||||
end
|
||||
|
||||
else
|
||||
dbg(cmd)
|
||||
core.console( cmd )
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
core.clearCommandBuffer()
|
||||
end
|
||||
print( string.rep('--',20) )
|
||||
|
||||
end
|
||||
|
||||
local function main(args)
|
||||
|
@ -143,20 +145,16 @@ local function main(args)
|
|||
print( string.rep('--',20) )
|
||||
print( string.rep('--',20) )
|
||||
|
||||
local outputTemplate = os.date("testpsk_%Y-%m-%d_%H%M%S")
|
||||
|
||||
-- Arguments for the script
|
||||
for o, arg in getopt.getopt(args, 'ho:') do
|
||||
for o, arg in getopt.getopt(args, 'h') do
|
||||
if o == "h" then return help() end
|
||||
if o == "o" then outputTemplate = arg end
|
||||
end
|
||||
|
||||
core.clearCommandBuffer()
|
||||
|
||||
pskTest(1)
|
||||
pskTest(2)
|
||||
pskTest(3)
|
||||
pskTest(8)
|
||||
test(1) -- PSK1
|
||||
--test(2) -- PSK2
|
||||
--test(3) -- PSK3
|
||||
|
||||
print( string.rep('--',20) )
|
||||
end
|
||||
|
@ -170,4 +168,4 @@ main(args)
|
|||
|
||||
-- XXXXX0XX = PSK RF/2
|
||||
-- XXXXX4XX = PSK RF/4
|
||||
-- XXXXX8XX = PSK RF/8
|
||||
-- XXXXX8XX = PSK RF/8
|
||||
|
|
|
@ -6,19 +6,20 @@ local dumplib = require('html_dumplib')
|
|||
|
||||
example =[[
|
||||
1. script run tracetest
|
||||
2. script run tracetest -o
|
||||
|
||||
]]
|
||||
author = "Iceman"
|
||||
usage = "script run tracetest -o <filename>"
|
||||
usage = "script run tracetest"
|
||||
desc =[[
|
||||
This script will load several traces files in ../traces/ folder and do
|
||||
"data load"
|
||||
"lf search"
|
||||
"lf search 1 u"
|
||||
|
||||
The following tracefiles will be loaded:
|
||||
em*.pm3
|
||||
m*.pm3
|
||||
|
||||
Arguments:
|
||||
-h : this help
|
||||
-o : logfile name
|
||||
]]
|
||||
|
||||
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
||||
|
@ -71,14 +72,14 @@ local function main(args)
|
|||
local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
|
||||
local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
|
||||
|
||||
local write2File = false
|
||||
local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
|
||||
|
||||
-- Arguments for the script
|
||||
for o, arg in getopt.getopt(args, 'ho:') do
|
||||
for o, arg in getopt.getopt(args, 'h') do
|
||||
if o == "h" then return help() end
|
||||
if o == "o" then outputTemplate = arg end
|
||||
end
|
||||
|
||||
|
||||
core.clearCommandBuffer()
|
||||
|
||||
local files = {}
|
||||
|
@ -97,7 +98,7 @@ local function main(args)
|
|||
end
|
||||
p.close();
|
||||
|
||||
local cmdLFSEARCH = "lf search 1"
|
||||
local cmdLFSEARCH = "lf search 1 u"
|
||||
|
||||
-- main loop
|
||||
io.write('Starting to test traces > ')
|
||||
|
@ -119,13 +120,6 @@ local function main(args)
|
|||
end
|
||||
io.write('\n')
|
||||
|
||||
-- Write dump to files
|
||||
if not DEBUG then
|
||||
local bar = dumplib.SaveAsText(emldata, outputTemplate..'.txt')
|
||||
print(("Wrote output to: %s"):format(bar))
|
||||
end
|
||||
|
||||
-- Show info
|
||||
print( string.rep('--',20) )
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue