chg: 'script run test_t55x7' - more modulations and better wipe card

This commit is contained in:
iceman1001 2019-04-05 08:21:10 +02:00
commit a499e30608

View file

@ -89,23 +89,134 @@ local function exitMsg(msg)
print(msg)
print()
end
---
-- ask/fsk/psk configuration blocks to test
local function GetConfigs( modulation )
local t = {}
t['ASK'] = {
[1] = '00008040',
[2] = '00048040',
[3] = '00088040',
[4] = '000c8040',
[5] = '00108040',
[6] = '00148040',
[7] = '00188040',
[8] = '001c8040',
}
t['BI'] = {
[1] = '00010040',
[2] = '00050040',
[3] = '00090040',
[4] = '000d0040',
[5] = '00110040',
[6] = '00150040',
[7] = '00190040',
[8] = '001d0040',
}
t['FSK2A'] = {
[1] = '00007040',
[2] = '00047040',
[3] = '00087040',
[4] = '000c7040',
[5] = '00107040',
[6] = '00147040',
[7] = '00187040',
[8] = '001c7040',
}
t['FSK1A'] = {
[1] = '00006040',
[2] = '00046040',
[3] = '00086040',
[4] = '000c6040',
[5] = '00106040',
[6] = '00146040',
[7] = '00186040',
[8] = '001c6040',
}
t['FSK2'] = {
[1] = '00005040',
[2] = '00045040',
[3] = '00085040',
[4] = '000c5040',
[5] = '00105040',
[6] = '00145040',
[7] = '00185040',
[8] = '001c5040',
}
t['FSK1'] = {
[1] = '00004040',
[2] = '00004040',
[3] = '00044040',
[4] = '00084040',
[5] = '000c4040',
[6] = '00104040',
[7] = '00144040',
[8] = '00184040',
[9] = '001c4040',
}
t['PSK1'] = {
[1] = '00001040',
[2] = '00041040',
[3] = '00081040',
[4] = '000c1040',
[5] = '00101040',
[6] = '00141040',
[7] = '00181040',
[8] = '001c1040',
}
t['PSK2'] = {
[1] = '00002040',
[2] = '00042040',
[3] = '00082040',
[4] = '000c2040',
[5] = '00102040',
[6] = '00142040',
[7] = '00182040',
[8] = '001c2040',
}
t['PSK3'] = {
[1] = '00003040',
[2] = '00043040',
[3] = '00083040',
[4] = '000c3040',
[5] = '00103040',
[6] = '00143040',
[7] = '00183040',
[8] = '001c3040',
}
return t[modulation]
end
---
-- lf t55xx wipe
local function WipeCard()
local wipe_cmds = {
[1] = 'lf t55xx wipe',
[2] = 'lf t55xx detect',
}
for _ = 1, #wipe_cmds do
local c = wipe_cmds[_]
dbg(c); core.console(c)
end
print('Wiping card')
core.console('lf t55xx wipe')
local wipe_data_cmd = "lf t55xx write b %s d %s"
for _ = 1, #data_blocks_cmds do
local val = data_blocks_cmds[_]
local c = string.format(wipe_data_cmd, _, val);
core.console(c)
print('Detecting card');
local res, msg = core.t55xx_detect()
if not res then
oops("can't detect modulation. Test failed.");
core.console("rem Failed to detect");
return false
else
local wipe_data_cmd = "lf t55xx write b %s d %s"
for _ = 1, #data_blocks_cmds do
local val = data_blocks_cmds[_]
local c = string.format(wipe_data_cmd, _, val);
core.console(c)
end
return true
end
end
---
@ -120,23 +231,18 @@ local function CheckReadBlock(block)
return ('%08X'):format(data)
end
local function test()
local function test(modulation)
-- PSK1 Modulations to test. (2blocks)
local process_block0_cmds = {
[1] = '00001040',
[2] = '00041040',
[3] = '00081040',
[4] = '000c1040',
[5] = '00101040',
[6] = '00141040',
[7] = '00181040',
[8] = '001c1040',
}
local process_block0_cmds = {}
local y
local block = "00"
local s = ('Start test of %s'):format(modulation)
print(s)
core.console('rem '..s)
process_block0_cmds = GetConfigs(modulation)
for _ = 1, #process_block0_cmds do
local p_config_cmd = process_block0_cmds[_]
@ -181,19 +287,20 @@ local function main(args)
end
core.clearCommandBuffer()
print('Starting test, wiping card')
WipeCard()
print('Detecting card')
local res, msg = core.t55xx_detect()
if res then
print('Starting test')
test()
else
print("can't detect modulation. Test failed. Ending.")
end
local res
-- test()
res = WipeCard()
if res then test("ASK") end
-- res = WipeCard()
-- if res then test("FSK1") end
-- res = WipeCard()
-- if res then test("FSK2") end
-- res = WipeCard()
-- if res then test("PSK1") end
exitMsg('Tests finished')
end