CHG: the default_toys.lua has the index bytes in mix endiansness. I tried to clean it up and verify them.

CHG: The tnp3clone.lua is now faster, and uses the "wipe" parameter to clean the tag before writing all data.
This commit is contained in:
iceman1001 2015-04-05 14:27:12 +02:00
commit 6c81ae5574
2 changed files with 72 additions and 52 deletions

View file

@ -109,24 +109,28 @@ local function main(args)
return oops('failed reading block with chinese magic command. quitting...')
end
end
local b1 = toytype..'000000000000000000000000'
-- wipe card.
local cmd = (cset..' %s 0004 08 w'):format( b0)
core.console(cmd)
local b1 = toytype..'000000000000000000000000'
local calc = utils.Crc16(b0..b1)
local calcEndian = bor(rsh(calc,8), lsh(band(calc, 0xff), 8))
local cmd = (cset..'1 %s%04x'):format( b1, calcEndian)
core.console( cmd)
core.console(cmd)
local pos, key
for blockNo = 2, numBlocks-1, 1 do
pos = (math.floor( blockNo / 4 ) * 12)+1
key = akeys:sub(pos, pos + 11 )
if blockNo%4 ~= 3 then
cmd = ('%s %d %s'):format(cset,blockNo,empty)
else
if blockNo%4 == 3 then
cmd = ('%s %d %s%s'):format(cset,blockNo,key,AccAndKeyB)
end
core.console(cmd)
core.console(cmd)
end
end
core.clearCommandBuffer()
end
main(args)