]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/test_t55x7_fsk.lua
CHG: the default_toys.lua has the index bytes in mix endiansness. I tried to clean...
[proxmark3-svn] / client / scripts / test_t55x7_fsk.lua
CommitLineData
ca65d3af 1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
5
6example =[[
7 1. script run test_t55x7_fsk
8]]
9author = "Iceman"
10usage = "script run test_t55x7_fsk"
11desc =[[
12This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
13The 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
25Loop:
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
37testsuit for the ASK/MANCHESTER demod
38
39Arguments:
40 -h : this help
41]]
42
43local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
44local DEBUG = true -- the debug flag
45
46--BLOCK 0 = 00008040 FSK
47local config1 = '00'
48local config2 = '040'
49
50local procedurecmds = {
51 [1] = '%s%02X%X%s',
52 [2] = 'lf t55xx detect',
53 [3] = 'lf t55xx info',
54}
55---
56-- A debug printout-function
57function 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
71end
72---
73-- This is only meant to be used when errors occur
74function oops(err)
75 print("ERROR: ",err)
76end
77---
78-- Usage help
79function help()
80 print(desc)
81 print("Example usage")
82 print(example)
83end
84--
85-- Exit message
86function ExitMsg(msg)
87 print( string.rep('--',20) )
88 print( string.rep('--',20) )
89 print(msg)
90 print()
91end
92
93function 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) )
120end
121
122local 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) )
138end
139main(args)
Impressum, Datenschutz