]> git.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/test_t55x7_psk.lua
update changelog
[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
47 -- local procedurecmds = {
48 -- [1] = '%s%s%s%s',
49 -- [2] = 'lf read',
50 -- --[3] = '',
51 -- [3] = 'data samples',
52 -- [4] = 'data pskdetectclock',
53 -- [5] = 'data psknrzrawdemod',
54 -- [6] = 'data pskindalademod',
55 -- }
56
57 -- --BLOCK 0 = 00 08 80 40 PSK
58 -- -----------
59 -- 08------- bitrate
60 -- 8----- modulation PSK1
61 -- 0---- PSK ClockRate
62 -- 40 max 2 blocks
63
64 local procedurecmds = {
65 [1] = '00%02X%X%X40',
66 [2] = 'lf t55xx detect',
67 --[3] = '',
68 [3] = 'lf t55xx info',
69 }
70 ---
71 -- A debug printout-function
72 function dbg(args)
73 if not DEBUG then
74 return
75 end
76
77 if type(args) == "table" then
78 local i = 1
79 while args[i] do
80 dbg(args[i])
81 i = i+1
82 end
83 else
84 print("###", args)
85 end
86 end
87 ---
88 -- This is only meant to be used when errors occur
89 function oops(err)
90 print("ERROR: ",err)
91 end
92 ---
93 -- Usage help
94 function help()
95 print(desc)
96 print("Example usage")
97 print(example)
98 end
99 --
100 -- Exit message
101 function ExitMsg(msg)
102 print( string.rep('--',20) )
103 print( string.rep('--',20) )
104 print(msg)
105 print()
106 end
107
108 function test(modulation)
109 local bitrate
110 local clockrate
111 for bitrate = 0x0, 0x1d, 0x4 do
112
113 for clockrate = 0,8,4 do
114
115 for _ = 1, #procedurecmds do
116 local cmd = procedurecmds[_]
117
118 if #cmd == 0 then
119
120 elseif _ == 1 then
121
122 dbg("Writing to T55x7 TAG")
123
124 local config = cmd:format(bitrate, modulation, clockrate)
125 dbg(('lf t55xx write 0 %s'):format(config))
126
127 config = tonumber(config,16)
128 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
129 local err = core.SendCommand(writecommand:getBytes())
130 if err then return oops(err) end
131 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
132 else
133 dbg(cmd)
134 core.console( cmd )
135 end
136 end
137 core.clearCommandBuffer()
138 end
139 end
140 print( string.rep('--',20) )
141 end
142
143 local function main(args)
144
145 print( string.rep('--',20) )
146 print( string.rep('--',20) )
147
148 -- Arguments for the script
149 for o, arg in getopt.getopt(args, 'h') do
150 if o == "h" then return help() end
151 end
152
153 core.clearCommandBuffer()
154
155 test(1) -- PSK1
156 --test(2) -- PSK2
157 --test(3) -- PSK3
158
159 print( string.rep('--',20) )
160 end
161 main(args)
162
163 -- Where it iterates over
164 -- xxxx8xxx = PSK RF/2 with Manchester modulation
165 -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
166 -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
167 -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
168
169 -- XXXXX0XX = PSK RF/2
170 -- XXXXX4XX = PSK RF/4
171 -- XXXXX8XX = PSK RF/8
Impressum, Datenschutz