2015-03-19 00:32:43 +08:00
|
|
|
local cmds = require('commands')
|
|
|
|
local getopt = require('getopt')
|
|
|
|
local bin = require('bin')
|
|
|
|
local utils = require('utils')
|
|
|
|
|
|
|
|
example =[[
|
2019-03-09 17:34:43 +08:00
|
|
|
1. script run test_t55x7_bi
|
2015-03-19 00:32:43 +08:00
|
|
|
]]
|
|
|
|
author = "Iceman"
|
|
|
|
usage = "script run test_t55x7_bi"
|
|
|
|
desc =[[
|
|
|
|
This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00010040
|
|
|
|
The outlined procedure is as following:
|
|
|
|
|
|
|
|
--BIPHASE 00010040
|
|
|
|
--
|
|
|
|
|
2017-07-31 21:26:53 +08:00
|
|
|
"lf t55xx write b 0 d 00010040"
|
2015-03-19 00:32:43 +08:00
|
|
|
"lf t55xx detect"
|
|
|
|
"lf t55xx info"
|
|
|
|
|
|
|
|
Loop:
|
2019-03-09 17:34:43 +08:00
|
|
|
change the configuretion block 0 with:
|
|
|
|
-xx01xxxx = RF/8
|
2015-03-19 00:32:43 +08:00
|
|
|
-xx05xxxx = RF/16
|
2019-03-09 17:34:43 +08:00
|
|
|
-xx09xxxx = RF/32
|
|
|
|
-xx0Dxxxx = RF/40
|
|
|
|
-xx11xxxx = RF/50
|
|
|
|
-xx15xxxx = RF/64
|
|
|
|
-xx19xxxx = RF/100
|
|
|
|
-xx1Dxxxx = RF/128
|
2015-03-19 00:32:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
testsuit for the BIPHASE demod
|
|
|
|
|
|
|
|
Arguments:
|
2019-03-09 17:34:43 +08:00
|
|
|
-h : this help
|
2015-03-19 00:32:43 +08:00
|
|
|
]]
|
|
|
|
|
|
|
|
local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
|
|
|
|
local DEBUG = true -- the debug flag
|
|
|
|
|
|
|
|
--BLOCK 0 = 00010040 BIPHASE
|
|
|
|
local config1 = '00'
|
|
|
|
local config2 = '0040'
|
|
|
|
|
|
|
|
local procedurecmds = {
|
2019-03-09 17:34:43 +08:00
|
|
|
[1] = '%s%02X%s',
|
|
|
|
[2] = 'lf t55xx detect',
|
|
|
|
[3] = 'lf t55xx info',
|
2015-03-19 00:32:43 +08:00
|
|
|
}
|
2019-03-09 17:34:43 +08:00
|
|
|
---
|
2015-03-19 00:32:43 +08:00
|
|
|
-- A debug printout-function
|
2017-07-31 21:26:53 +08:00
|
|
|
local function dbg(args)
|
2019-03-09 17:34:43 +08:00
|
|
|
if not DEBUG then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-03-19 00:32:43 +08:00
|
|
|
if type(args) == "table" then
|
2019-03-09 17:34:43 +08:00
|
|
|
local i = 1
|
|
|
|
while args[i] do
|
|
|
|
dbg(args[i])
|
|
|
|
i = i+1
|
|
|
|
end
|
|
|
|
else
|
|
|
|
print("###", args)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
---
|
2015-03-19 00:32:43 +08:00
|
|
|
-- This is only meant to be used when errors occur
|
2017-07-31 21:26:53 +08:00
|
|
|
local function oops(err)
|
2019-03-09 17:34:43 +08:00
|
|
|
print("ERROR: ",err)
|
2015-03-19 00:32:43 +08:00
|
|
|
end
|
2019-03-09 17:34:43 +08:00
|
|
|
---
|
2015-03-19 00:32:43 +08:00
|
|
|
-- Usage help
|
2017-07-31 21:26:53 +08:00
|
|
|
local function help()
|
2019-03-09 17:34:43 +08:00
|
|
|
print(desc)
|
|
|
|
print("Example usage")
|
|
|
|
print(example)
|
2015-03-19 00:32:43 +08:00
|
|
|
end
|
|
|
|
--
|
|
|
|
-- Exit message
|
2017-07-31 21:26:53 +08:00
|
|
|
local function ExitMsg(msg)
|
2019-03-09 17:34:43 +08:00
|
|
|
print( string.rep('--',20) )
|
|
|
|
print( string.rep('--',20) )
|
|
|
|
print(msg)
|
|
|
|
print()
|
2015-03-19 00:32:43 +08:00
|
|
|
end
|
|
|
|
|
2017-07-31 21:26:53 +08:00
|
|
|
local function test()
|
2019-03-09 17:34:43 +08:00
|
|
|
local y
|
|
|
|
local block = "00"
|
|
|
|
for y = 1, 0x1D, 4 do
|
|
|
|
for _ = 1, #procedurecmds do
|
|
|
|
local pcmd = procedurecmds[_]
|
|
|
|
|
|
|
|
if #pcmd == 0 then
|
|
|
|
|
|
|
|
elseif _ == 1 then
|
|
|
|
|
|
|
|
local config = pcmd:format(config1, y, config2)
|
|
|
|
dbg(('lf t55xx write b 0 d %s'):format(config))
|
|
|
|
|
|
|
|
config = tonumber(config,16)
|
|
|
|
local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK,arg1 = config, arg2 = block, arg3 = "00", data = "00"}
|
|
|
|
local err = core.SendCommand(writecmd:getBytes())
|
|
|
|
if err then return oops(err) end
|
|
|
|
local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
|
|
|
|
else
|
|
|
|
dbg(pcmd)
|
|
|
|
core.console( pcmd )
|
|
|
|
end
|
|
|
|
end
|
|
|
|
core.clearCommandBuffer()
|
|
|
|
end
|
|
|
|
print( string.rep('--',20) )
|
2015-03-19 00:32:43 +08:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local function main(args)
|
|
|
|
|
2019-03-09 17:34:43 +08:00
|
|
|
print( string.rep('--',20) )
|
|
|
|
print( string.rep('--',20) )
|
2015-03-19 00:32:43 +08:00
|
|
|
|
2019-03-09 17:34:43 +08:00
|
|
|
-- Arguments for the script
|
|
|
|
for o, arg in getopt.getopt(args, 'h') do
|
|
|
|
if o == "h" then return help() end
|
|
|
|
end
|
2015-03-19 00:32:43 +08:00
|
|
|
|
2019-03-09 17:34:43 +08:00
|
|
|
core.clearCommandBuffer()
|
|
|
|
test()
|
|
|
|
print( string.rep('--',20) )
|
2015-03-19 00:32:43 +08:00
|
|
|
end
|
2015-03-23 03:28:48 +08:00
|
|
|
main(args)
|