]> cvs.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/test_t55x7_fsk.lua
fix bug in pskdemod return value if no samples...
[proxmark3-svn] / client / scripts / test_t55x7_fsk.lua
CommitLineData
13d77ef9 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
224ce36e 95 local block = "00"
13d77ef9 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)
224ce36e 108 local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 = config, arg2 = block, arg3 = "00", data = "00"}
13d77ef9 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) )
121end
122
123local 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) )
139end
140main(args)
Impressum, Datenschutz