1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
5 local dumplib = require('html_dumplib')
8 1. script run tracetest
9 2. script run tracetest -o
13 usage = "script run test_t55x7_psk -o <filename>"
15 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
16 The outlined procedure is as following:
18 "lf t55xx write 0 00088040"
27 change the configuretion block 0 with:
28 -xxxx8xxx = PSK RF/2 with Manchester modulation
29 -xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
30 -xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
31 -xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
33 for each outer configuration, also do
38 In all 12 individual test for the PSK demod
45 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
46 local DEBUG = true -- the debug flag
49 local config1 = '0008'
52 local procedurecmds = {
57 [4] = 'data pskdetectclock',
58 [5] = 'data psknrzrawdemod',
59 [6] = 'data pskindalademod',
63 -- A debug printout-function
69 if type(args) == "table" then
80 -- This is only meant to be used when errors occur
88 print("Example usage")
94 print( string.rep('--',20) )
95 print( string.rep('--',20) )
100 function pskTest(modulation)
103 for _ = 1, #procedurecmds do
104 local cmd = procedurecmds[_]
110 dbg("Writing to T55x7 TAG")
112 local configdata = cmd:format( config1, modulation , y, config2)
116 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = configdata ,arg2 = 0, arg3 = 0}
117 local err = core.SendCommand(writecommand:getBytes())
118 if err then return oops(err) end
119 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
122 local count,cmd,arg0 = bin.unpack('LL',response)
124 dbg("Writing success")
126 return nil, "Couldn't read block.."
135 core.clearCommandBuffer()
137 print( string.rep('--',20) )
141 local function main(args)
143 print( string.rep('--',20) )
144 print( string.rep('--',20) )
146 local outputTemplate = os.date("testpsk_%Y-%m-%d_%H%M%S")
148 -- Arguments for the script
149 for o, arg in getopt.getopt(args, 'ho:') do
150 if o == "h" then return help() end
151 if o == "o" then outputTemplate = arg end
154 core.clearCommandBuffer()
161 print( string.rep('--',20) )
165 -- Where it iterates over
166 -- xxxx8xxx = PSK RF/2 with Manchester modulation
167 -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
168 -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
169 -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
171 -- XXXXX0XX = PSK RF/2
172 -- XXXXX4XX = PSK RF/4
173 -- XXXXX8XX = PSK RF/8