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