]> cvs.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/scripts/test_t55x7_psk.lua
ADD: printConfiguration method for a nice printout of the selected configuration.
[proxmark3-svn] / client / scripts / test_t55x7_psk.lua
... / ...
CommitLineData
1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
5local dumplib = require('html_dumplib')
6
7example =[[
8 1. script run tracetest
9 2. script run tracetest -o
10
11]]
12author = "Iceman"
13usage = "script run test_t55x7_psk -o <filename>"
14desc =[[
15This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
16The outlined procedure is as following:
17
18"lf t55xx write 0 00088040"
19"lf read"
20"data samples"
21"data pskdet"
22"data psknrz"
23"data pskindala"
24"data psknrzraw"
25
26Loop OUTER:
27 change the configuretion block 0 with:
28 -xxxx8xxx = PSK RF/2 with Manchester modulation
29 -xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
30 -xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
31 -xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
32 Loop INNER
33 for each outer configuration, also do
34 XXXXX0XX = PSK RF/2
35 XXXXX4XX = PSK RF/4
36 XXXXX8XX = PSK RF/8
37
38In all 12 individual test for the PSK demod
39
40Arguments:
41 -h : this help
42 -o : logfile name
43]]
44
45local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
46local DEBUG = true -- the debug flag
47
48--BLOCK 0 = 00088040
49local config1 = '0008'
50local config2 = '40'
51
52local procedurecmds = {
53 [1] = '%s%s%s%s',
54 [2] = 'lf read',
55 --[3] = '',
56 [3] = 'data samples',
57 [4] = 'data pskdetectclock',
58 [5] = 'data psknrzrawdemod',
59 [6] = 'data pskindalademod',
60}
61
62---
63-- A debug printout-function
64function dbg(args)
65 if not DEBUG then
66 return
67 end
68
69 if type(args) == "table" then
70 local i = 1
71 while args[i] do
72 dbg(args[i])
73 i = i+1
74 end
75 else
76 print("###", args)
77 end
78end
79---
80-- This is only meant to be used when errors occur
81function oops(err)
82 print("ERROR: ",err)
83end
84---
85-- Usage help
86function help()
87 print(desc)
88 print("Example usage")
89 print(example)
90end
91--
92-- Exit message
93function ExitMsg(msg)
94 print( string.rep('--',20) )
95 print( string.rep('--',20) )
96 print(msg)
97 print()
98end
99
100function pskTest(modulation)
101 local y
102 for y = 0, 8, 4 do
103 for _ = 1, #procedurecmds do
104 local cmd = procedurecmds[_]
105
106 if #cmd == 0 then
107
108 elseif _ == 1 then
109
110 dbg("Writing to T55x7 TAG")
111
112 local configdata = cmd:format( config1, modulation , y, config2)
113
114 dbg( configdata)
115
116 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = configdata ,arg2 = 0, arg3 = 0}
117 local err = core.SendCommand(writecommand:getBytes())
118 if err then return oops(err) end
119 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
120
121 if response then
122 local count,cmd,arg0 = bin.unpack('LL',response)
123 if(arg0==1) then
124 dbg("Writing success")
125 else
126 return nil, "Couldn't read block.."
127 end
128 end
129
130 else
131 dbg(cmd)
132 core.console( cmd )
133 end
134 end
135 core.clearCommandBuffer()
136 end
137 print( string.rep('--',20) )
138
139end
140
141local function main(args)
142
143 print( string.rep('--',20) )
144 print( string.rep('--',20) )
145
146 local outputTemplate = os.date("testpsk_%Y-%m-%d_%H%M%S")
147
148 -- Arguments for the script
149 for o, arg in getopt.getopt(args, 'ho:') do
150 if o == "h" then return help() end
151 if o == "o" then outputTemplate = arg end
152 end
153
154 core.clearCommandBuffer()
155
156 pskTest(1)
157 pskTest(2)
158 pskTest(3)
159 pskTest(8)
160
161 print( string.rep('--',20) )
162end
163main(args)
164
165-- Where it iterates over
166 -- xxxx8xxx = PSK RF/2 with Manchester modulation
167 -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
168 -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
169 -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
170
171 -- XXXXX0XX = PSK RF/2
172 -- XXXXX4XX = PSK RF/4
173 -- XXXXX8XX = PSK RF/8
Impressum, Datenschutz