]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/test_t55x7_ask.lua
fix: compile issue on RasPi (http://www.proxmark.org/forum/viewtopic.php?id=4678)
[proxmark3-svn] / client / scripts / test_t55x7_ask.lua
CommitLineData
13d77ef9 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
224ce36e 98 local block = "00"
13d77ef9 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
224ce36e 111 local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 = config, arg2 = block, arg3 = "00", data = "00"}
13d77ef9 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) )
124end
125
126local 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) )
139end
140main(args)
Impressum, Datenschutz