]> git.zerfleddert.de Git - proxmark3-svn/blame_incremental - client/scripts/test_t55x7_ask.lua
CHG: Added the parameters -fdata-sections -ffunction-sections to common/Makefile...
[proxmark3-svn] / client / scripts / test_t55x7_ask.lua
... / ...
CommitLineData
1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
5
6local format=string.format
7local floor=math.floor
8
9example =[[
10 1. script run test_t55x7_ask
11]]
12author = "Iceman"
13usage = "script run test_t55x7_ask"
14desc =[[
15This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
16The 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
28Loop:
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
40testsuit for the ASK/MANCHESTER demod
41
42Arguments:
43 -h : this help
44]]
45
46local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
47local DEBUG = true -- the debug flag
48
49--BLOCK 0 = 00008040 ASK / MAN
50local config1 = '00'
51local config2 = '8040'
52
53local procedurecmds = {
54 [1] = '%s%02X%s',
55 [2] = 'lf t55xx detect',
56 [3] = 'lf t55xx info',
57}
58---
59-- A debug printout-function
60function 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
74end
75---
76-- This is only meant to be used when errors occur
77function oops(err)
78 print("ERROR: ",err)
79end
80---
81-- Usage help
82function help()
83 print(desc)
84 print("Example usage")
85 print(example)
86end
87--
88-- Exit message
89function ExitMsg(msg)
90 print( string.rep('--',20) )
91 print( string.rep('--',20) )
92 print(msg)
93 print()
94end
95
96function 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) )
123end
124
125local 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) )
138end
139main(args)
Impressum, Datenschutz