]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/test_t55x7_psk.lua
ADD: new tests for the T55XX commands.
[proxmark3-svn] / client / scripts / test_t55x7_psk.lua
CommitLineData
f004ba08 1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
f004ba08 5
6example =[[
ca65d3af 7 1. script run test_t55x7_psk
8 2. script run test_t55x7_psk -o
f004ba08 9
10]]
11author = "Iceman"
ca65d3af 12usage = "script run test_t55x7_psk"
f004ba08 13desc =[[
14This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
15The outlined procedure is as following:
16
17"lf t55xx write 0 00088040"
18"lf read"
19"data samples"
20"data pskdet"
21"data psknrz"
22"data pskindala"
23"data psknrzraw"
24
25Loop OUTER:
26 change the configuretion block 0 with:
27 -xxxx8xxx = PSK RF/2 with Manchester modulation
28 -xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
29 -xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
30 -xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
31 Loop INNER
32 for each outer configuration, also do
33 XXXXX0XX = PSK RF/2
34 XXXXX4XX = PSK RF/4
35 XXXXX8XX = PSK RF/8
36
37In all 12 individual test for the PSK demod
38
39Arguments:
40 -h : this help
f004ba08 41]]
42
43local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
44local DEBUG = true -- the debug flag
45
ca65d3af 46--BLOCK 0 = 00088040 PSK
47local config1 = '0014'
f004ba08 48local config2 = '40'
49
ca65d3af 50-- local procedurecmds = {
51 -- [1] = '%s%s%s%s',
52 -- [2] = 'lf read',
53 -- --[3] = '',
54 -- [3] = 'data samples',
55 -- [4] = 'data pskdetectclock',
56 -- [5] = 'data psknrzrawdemod',
57 -- [6] = 'data pskindalademod',
58-- }
59
f004ba08 60local procedurecmds = {
61 [1] = '%s%s%s%s',
ca65d3af 62 [2] = 'lf t55xx detect',
f004ba08 63 --[3] = '',
ca65d3af 64 [3] = 'lf t55xx info',
f004ba08 65}
f004ba08 66---
67-- A debug printout-function
68function dbg(args)
69 if not DEBUG then
70 return
71 end
72
73 if type(args) == "table" then
74 local i = 1
75 while args[i] do
76 dbg(args[i])
77 i = i+1
78 end
79 else
80 print("###", args)
81 end
82end
83---
84-- This is only meant to be used when errors occur
85function oops(err)
86 print("ERROR: ",err)
87end
88---
89-- Usage help
90function help()
91 print(desc)
92 print("Example usage")
93 print(example)
94end
95--
96-- Exit message
97function ExitMsg(msg)
98 print( string.rep('--',20) )
99 print( string.rep('--',20) )
100 print(msg)
101 print()
102end
103
ca65d3af 104function test(modulation)
f004ba08 105 local y
106 for y = 0, 8, 4 do
107 for _ = 1, #procedurecmds do
108 local cmd = procedurecmds[_]
109
110 if #cmd == 0 then
111
112 elseif _ == 1 then
113
114 dbg("Writing to T55x7 TAG")
115
ca65d3af 116 local config = cmd:format( config1, modulation , y, config2)
117 dbg(('lf t55xx write 0 %s'):format(config))
f004ba08 118
ca65d3af 119 config = tonumber(config,16)
120 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
f004ba08 121 local err = core.SendCommand(writecommand:getBytes())
122 if err then return oops(err) end
123 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
f004ba08 124 else
125 dbg(cmd)
126 core.console( cmd )
127 end
128 end
129 core.clearCommandBuffer()
130 end
131 print( string.rep('--',20) )
f004ba08 132end
133
134local function main(args)
135
136 print( string.rep('--',20) )
137 print( string.rep('--',20) )
138
f004ba08 139 -- Arguments for the script
ca65d3af 140 for o, arg in getopt.getopt(args, 'h') do
f004ba08 141 if o == "h" then return help() end
f004ba08 142 end
143
144 core.clearCommandBuffer()
145
ca65d3af 146 test(1)
147 test(2)
148 test(3)
149 test(8)
f004ba08 150
151 print( string.rep('--',20) )
152end
153main(args)
154
155-- Where it iterates over
156 -- xxxx8xxx = PSK RF/2 with Manchester modulation
157 -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
158 -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
159 -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
160
161 -- XXXXX0XX = PSK RF/2
162 -- XXXXX4XX = PSK RF/4
163 -- XXXXX8XX = PSK RF/8
Impressum, Datenschutz