1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
7 1. script run test_t55x7_psk
8 2. script run test_t55x7_psk -o
12 usage = "script run test_t55x7_psk"
14 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
15 The outlined procedure is as following:
17 "lf t55xx write 0 00088040"
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)
32 for each outer configuration, also do
37 In all 12 individual test for the PSK demod
43 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
44 local DEBUG = true -- the debug flag
46 --BLOCK 0 = 00088040 PSK
47 local config1 = '0014'
50 -- local procedurecmds = {
54 -- [3] = 'data samples',
55 -- [4] = 'data pskdetectclock',
56 -- [5] = 'data psknrzrawdemod',
57 -- [6] = 'data pskindalademod',
60 local procedurecmds = {
62 [2] = 'lf t55xx detect',
64 [3] = 'lf t55xx info',
67 -- A debug printout-function
73 if type(args) == "table" then
84 -- This is only meant to be used when errors occur
92 print("Example usage")
98 print( string.rep('--',20) )
99 print( string.rep('--',20) )
104 function test(modulation)
107 for _ = 1, #procedurecmds do
108 local cmd = procedurecmds[_]
114 dbg("Writing to T55x7 TAG")
116 local config = cmd:format( config1, modulation , y, config2)
117 dbg(('lf t55xx write 0 %s'):format(config))
119 config = tonumber(config,16)
120 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
121 local err = core.SendCommand(writecommand:getBytes())
122 if err then return oops(err) end
123 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
129 core.clearCommandBuffer()
131 print( string.rep('--',20) )
134 local function main(args)
136 print( string.rep('--',20) )
137 print( string.rep('--',20) )
139 -- Arguments for the script
140 for o, arg in getopt.getopt(args, 'h') do
141 if o == "h" then return help() end
144 core.clearCommandBuffer()
151 print( string.rep('--',20) )
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)
161 -- XXXXX0XX = PSK RF/2
162 -- XXXXX4XX = PSK RF/4
163 -- XXXXX8XX = PSK RF/8