1 local cmds
= require('commands')
2 local getopt
= require('getopt')
3 local bin
= require('bin')
4 local utils
= require('utils')
5 local ansicolors
= require('ansicolors')
11 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00010040
12 The outlined procedure is as following:
17 "lf t55xx write -b 0 -d 00010040"
22 change the configuretion block 0 with:
33 testsuit for the BIPHASE demod
36 1. script run lf_t55xx_defaultbi
39 script run lf_t55xx_defaultbi [-h]
45 local DEBUG
= true -- the debug flag
48 --BLOCK 0 = 00010040 BIPHASE
50 local config2
= '0040'
52 local procedurecmds
= {
54 [2] = 'lf t55xx detect',
55 [3] = 'lf t55xx info',
58 -- A debug printout-function
59 local function dbg(args
)
60 if not DEBUG
then return end
61 if type(args
) == 'table' then
72 -- This is only meant to be used when errors occur
73 local function oops(err
)
75 core
.clearCommandBuffer()
85 print(ansicolors
.cyan
..'Usage'..ansicolors
.reset
)
87 print(ansicolors
.cyan
..'Arguments'..ansicolors
.reset
)
89 print(ansicolors
.cyan
..'Example usage'..ansicolors
.reset
)
94 local function ExitMsg(msg
)
95 print( string.rep('--',20) )
96 print( string.rep('--',20) )
101 local function test()
103 local password
= '00000000'
106 for y
= 1, 0x1D, 4 do
107 for _
= 1, #procedurecmds
do
108 local pcmd
= procedurecmds
[_
]
114 local config
= pcmd
:format(config1
, y
, config2
)
115 dbg(('lf t55xx write -b 0 -d %s'):format(config
))
117 local data
= ('%s%s%s%s'):format(utils
.SwapEndiannessStr(config
, 32), password
, block
, flags
)
119 local wc
= Command
:newNG
{cmd
= cmds
.CMD_LF_T55XX_WRITEBL
, data
= data
}
120 local response
, err
= wc
:sendNG(false, TIMEOUT
)
122 if not response
then return oops(err
) end
128 core
.clearCommandBuffer()
130 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()
146 print( string.rep('--',20) )