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 -- local procedurecmds = {
50 -- [3] = 'data samples',
51 -- [4] = 'data pskdetectclock',
52 -- [5] = 'data psknrzrawdemod',
53 -- [6] = 'data pskindalademod',
56 -- --BLOCK 0 = 00 08 80 40 PSK
59 -- 8----- modulation PSK1
60 -- 0---- PSK ClockRate
63 local procedurecmds = {
65 [2] = 'lf t55xx detect',
67 [3] = 'lf t55xx info',
70 -- A debug printout-function
76 if type(args) == "table" then
87 -- This is only meant to be used when errors occur
95 print("Example usage")
100 function ExitMsg(msg)
101 print( string.rep('--',20) )
102 print( string.rep('--',20) )
107 function test(modulation)
110 for bitrate = 0x0, 0x1d, 0x4 do
112 for clockrate = 0,8,4 do
113 local cmd = procedurecmds[_]
119 dbg("Writing to T55x7 TAG")
121 local config = cmd:format(bitrate, modulation, clockrate)
122 dbg(('lf t55xx write 0 %s'):format(config))
124 config = tonumber(config,16)
125 local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
126 local err = core.SendCommand(writecommand:getBytes())
127 if err then return oops(err) end
128 local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
135 print( string.rep('--',20) )
138 local function main(args)
140 print( string.rep('--',20) )
141 print( string.rep('--',20) )
143 -- Arguments for the script
144 for o, arg in getopt.getopt(args, 'h') do
145 if o == "h" then return help() end
148 core.clearCommandBuffer()
154 print( string.rep('--',20) )