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
47 -- local procedurecmds = {
51 -- [3] = 'data samples',
52 -- [4] = 'data pskdetectclock',
53 -- [5] = 'data psknrzrawdemod',
54 -- [6] = 'data pskindalademod',
57 -- --BLOCK 0 = 00 08 80 40 PSK
60 -- 8----- modulation PSK1
61 -- 0---- PSK ClockRate
64 local procedurecmds
= {
66 [2] = 'lf t55xx detect',
68 [3] = 'lf t55xx info',
71 -- A debug printout-function
77 if type(args
) == "table" then
88 -- This is only meant to be used when errors occur
96 print("Example usage")
101 function ExitMsg(msg
)
102 print( string.rep('--',20) )
103 print( string.rep('--',20) )
108 function test(modulation
)
112 for bitrate
= 0x0, 0x1d, 0x4 do
114 for clockrate
= 0,8,4 do
116 for _
= 1, #procedurecmds
do
117 local cmd
= procedurecmds
[_
]
123 dbg("Writing to T55x7 TAG")
125 local config
= cmd
:format(bitrate
, modulation
, clockrate
)
126 dbg(('lf t55xx write 0 %s'):format(config
))
128 config
= tonumber(config
,16)
129 local writecmd
= Command
:new
{cmd
= cmds
.CMD_T55XX_WRITE_BLOCK
,arg1
= config
, arg2
= block
, arg3
= "00", data
= "00"}
130 local err
= core
.SendCommand(writecmd
:getBytes())
131 if err
then return oops(err
) end
132 local response
= core
.WaitForResponseTimeout(cmds
.CMD_ACK
,TIMEOUT
)
138 core
.clearCommandBuffer()
141 print( string.rep('--',20) )
144 local function main(args
)
146 print( string.rep('--',20) )
147 print( string.rep('--',20) )
149 -- Arguments for the script
150 for o
, arg
in getopt
.getopt(args
, 'h') do
151 if o
== "h" then return help() end
154 core
.clearCommandBuffer()
160 print( string.rep('--',20) )
164 -- Where it iterates over
165 -- xxxx8xxx = PSK RF/2 with Manchester modulation
166 -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
167 -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
168 -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
170 -- XXXXX0XX = PSK RF/2
171 -- XXXXX4XX = PSK RF/4
172 -- XXXXX8XX = PSK RF/8