]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/test_t55x7_ask.lua
ADD: new tests for the T55XX commands.
[proxmark3-svn] / client / scripts / test_t55x7_ask.lua
1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
5
6 local format=string.format
7 local floor=math.floor
8
9 example =[[
10 1. script run test_t55x7_ask
11 ]]
12 author = "Iceman"
13 usage = "script run test_t55x7_ask"
14 desc =[[
15 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
16 The outlined procedure is as following:
17
18 --ASK
19 00 00 80 40
20 -- max 2
21 -- manchester
22 -- bit rate
23
24 "lf t55xx write 0 00008040"
25 "lf t55xx detect"
26 "lf t55xx info"
27
28 Loop:
29 change the configuretion block 0 with:
30 -xx 00 xxxx = RF/8
31 -xx 04 xxxx = RF/16
32 -xx 08 xxxx = RF/32
33 -xx 0C xxxx = RF/40
34 -xx 10 xxxx = RF/50
35 -xx 14 xxxx = RF/64
36 -xx 18 xxxx = RF/100
37 -xx 1C xxxx = RF/128
38
39
40 testsuit for the ASK/MANCHESTER demod
41
42 Arguments:
43 -h : this help
44 ]]
45
46 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
47 local DEBUG = true -- the debug flag
48
49 --BLOCK 0 = 00008040 ASK / MAN
50 local config1 = '00'
51 local config2 = '8040'
52
53 local procedurecmds = {
54 [1] = '%s%02X%s',
55 [2] = 'lf t55xx detect',
56 [3] = 'lf t55xx info',
57 }
58 ---
59 -- A debug printout-function
60 function dbg(args)
61 if not DEBUG then
62 return
63 end
64
65 if type(args) == "table" then
66 local i = 1
67 while args[i] do
68 dbg(args[i])
69 i = i+1
70 end
71 else
72 print("###", args)
73 end
74 end
75 ---
76 -- This is only meant to be used when errors occur
77 function oops(err)
78 print("ERROR: ",err)
79 end
80 ---
81 -- Usage help
82 function help()
83 print(desc)
84 print("Example usage")
85 print(example)
86 end
87 --
88 -- Exit message
89 function ExitMsg(msg)
90 print( string.rep('--',20) )
91 print( string.rep('--',20) )
92 print(msg)
93 print()
94 end
95
96 function test()
97 local y
98 for y = 0x0, 0x1d, 0x4 do
99 for _ = 1, #procedurecmds do
100 local pcmd = procedurecmds[_]
101
102 if #pcmd == 0 then
103
104 elseif _ == 1 then
105
106 local config = pcmd:format(config1, y, config2)
107 dbg(('lf t55xx write 0 %s'):format(config))
108 config = tonumber(config,16)
109
110 local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}
111 local err = core.SendCommand(writecmd:getBytes())
112 if err then return oops(err) end
113 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
114
115 else
116 dbg(pcmd)
117 core.console( pcmd )
118 end
119 end
120 core.clearCommandBuffer()
121 end
122 print( string.rep('--',20) )
123 end
124
125 local function main(args)
126
127 print( string.rep('--',20) )
128 print( string.rep('--',20) )
129
130 -- Arguments for the script
131 for o, arg in getopt.getopt(args, 'h') do
132 if o == "h" then return help() end
133 end
134
135 core.clearCommandBuffer()
136 test()
137 print( string.rep('--',20) )
138 end
139 main(args)
Impressum, Datenschutz