]> git.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/test_t55x7_bi.lua
fix: compile issue on RasPi (http://www.proxmark.org/forum/viewtopic.php?id=4678)
[proxmark3-svn] / client / scripts / test_t55x7_bi.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_bi
8 ]]
9 author = "Iceman"
10 usage = "script run test_t55x7_bi"
11 desc =[[
12 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00010040
13 The outlined procedure is as following:
14
15 --BIPHASE 00010040
16 --
17
18 "lf t55xx write 0 00010040"
19 "lf t55xx detect"
20 "lf t55xx info"
21
22 Loop:
23 change the configuretion block 0 with:
24 -xx01xxxx = RF/8
25 -xx05xxxx = RF/16
26 -xx09xxxx = RF/32
27 -xx0Dxxxx = RF/40
28 -xx11xxxx = RF/50
29 -xx15xxxx = RF/64
30 -xx19xxxx = RF/100
31 -xx1Dxxxx = RF/128
32
33
34 testsuit for the BIPHASE demod
35
36 Arguments:
37 -h : this help
38 ]]
39
40 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
41 local DEBUG = true -- the debug flag
42
43 --BLOCK 0 = 00010040 BIPHASE
44 local config1 = '00'
45 local config2 = '0040'
46
47 local procedurecmds = {
48 [1] = '%s%02X%s',
49 [2] = 'lf t55xx detect',
50 [3] = 'lf t55xx info',
51 }
52 ---
53 -- A debug printout-function
54 function dbg(args)
55 if not DEBUG then
56 return
57 end
58
59 if type(args) == "table" then
60 local i = 1
61 while args[i] do
62 dbg(args[i])
63 i = i+1
64 end
65 else
66 print("###", args)
67 end
68 end
69 ---
70 -- This is only meant to be used when errors occur
71 function oops(err)
72 print("ERROR: ",err)
73 end
74 ---
75 -- Usage help
76 function help()
77 print(desc)
78 print("Example usage")
79 print(example)
80 end
81 --
82 -- Exit message
83 function ExitMsg(msg)
84 print( string.rep('--',20) )
85 print( string.rep('--',20) )
86 print(msg)
87 print()
88 end
89
90 function test()
91 local y
92 local block = "00"
93 for y = 1, 0x1D, 4 do
94 for _ = 1, #procedurecmds do
95 local pcmd = procedurecmds[_]
96
97 if #pcmd == 0 then
98
99 elseif _ == 1 then
100
101 local config = pcmd:format(config1, y, config2)
102 dbg(('lf t55xx write 0 %s'):format(config))
103
104 config = tonumber(config,16)
105 local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 = config, arg2 = block, arg3 = "00", data = "00"}
106 local err = core.SendCommand(writecmd:getBytes())
107 if err then return oops(err) end
108 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
109 else
110 dbg(pcmd)
111 core.console( pcmd )
112 end
113 end
114 core.clearCommandBuffer()
115 end
116 print( string.rep('--',20) )
117
118 end
119
120 local function main(args)
121
122 print( string.rep('--',20) )
123 print( string.rep('--',20) )
124
125 -- Arguments for the script
126 for o, arg in getopt.getopt(args, 'h') do
127 if o == "h" then return help() end
128 end
129
130 core.clearCommandBuffer()
131 test()
132 print( string.rep('--',20) )
133 end
134 main(args)
Impressum, Datenschutz