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