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