]> cvs.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/test_t55x7_ask.lua
FIX: coverity scan error CID 121781, unused value. error 0x88 will be overritten...
[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 local block = "00"
99 for y = 0x0, 0x1d, 0x4 do
100 for _ = 1, #procedurecmds do
101 local pcmd = procedurecmds[_]
102
103 if #pcmd == 0 then
104
105 elseif _ == 1 then
106
107 local config = pcmd:format(config1, y, config2)
108 dbg(('lf t55xx write 0 %s'):format(config))
109 config = tonumber(config,16)
110
111 local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 = config, arg2 = block, arg3 = "00", data = "00"}
112 local err = core.SendCommand(writecmd:getBytes())
113 if err then return oops(err) end
114 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
115
116 else
117 dbg(pcmd)
118 core.console( pcmd )
119 end
120 end
121 core.clearCommandBuffer()
122 end
123 print( string.rep('--',20) )
124 end
125
126 local function main(args)
127
128 print( string.rep('--',20) )
129 print( string.rep('--',20) )
130
131 -- Arguments for the script
132 for o, arg in getopt.getopt(args, 'h') do
133 if o == "h" then return help() end
134 end
135
136 core.clearCommandBuffer()
137 test()
138 print( string.rep('--',20) )
139 end
140 main(args)
Impressum, Datenschutz