adapt lua script to handle PS odd 32b limit, my best guess the WIN32 macro is set.

This commit is contained in:
iceman1001 2021-02-20 08:36:33 +01:00
commit e13108023a

View file

@ -4,7 +4,7 @@ local ac = require('ansicolors')
copyright = '' copyright = ''
author = "Christian Herrmann" author = "Christian Herrmann"
version = 'v1.0.0' version = 'v1.0.1'
desc = [[ desc = [[
Perform bulk EM410x enrollment of T5577 RFID tags. It keeps track of last card id used. Perform bulk EM410x enrollment of T5577 RFID tags. It keeps track of last card id used.
If called with -s, this value resets "session". If called with -s, this value resets "session".
@ -84,20 +84,21 @@ local function readfile()
end end
local t = f:read("*all") local t = f:read("*all")
f:close() f:close()
local cn = tonumber(t, 16) local cn_hi = tonumber(t:sub(1, 2), 16)
print(('Using EM4100 ID '..ac.green..'%010X'..ac.reset..' from `'..ac.yellow..'%s'..ac.reset..'`'):format(cn, ENROLL_STATUS_FN)) local cn_low = tonumber(t:sub(3, 10), 16)
return cn print(('Using EM4100 ID '..ac.green..'%02X%08X'..ac.reset..' from `'..ac.yellow..'%s'..ac.reset..'`'):format(cn_hi, cn_low, ENROLL_STATUS_FN))
return cn_hi, cn_low
end end
--- ---
-- --
local function writefile(cn) local function writefile(cn_hi, cn_low)
local f = io.open(ENROLL_STATUS_FN, "w") local f = io.open(ENROLL_STATUS_FN, "w")
if f == nil then if f == nil then
return nil, string.format("Could not write to file %s", ENROLL_STATUS_FN) return nil, string.format("Could not write to file %s", ENROLL_STATUS_FN)
end end
f:write(("%010X\n"):format(cn)) f:write(("%02X%08X\n"):format(cn_hi, cn_low))
f:close() f:close()
print(('Wrote EM4100 ID '..ac.green..'%010X'..ac.reset..' to `'..ac.yellow..'%s'..ac.reset..'`'):format(cn, ENROLL_STATUS_FN)) print(('Wrote EM4100 ID '..ac.green..'%02X%08X'..ac.reset..' to `'..ac.yellow..'%s'..ac.reset..'`'):format(cn_hi, cn_low, ENROLL_STATUS_FN))
return true, 'Ok' return true, 'Ok'
end end
@ -134,32 +135,32 @@ local function main(args)
core.console('pref set hint --off') core.console('pref set hint --off')
print('') print('')
local sid = tonumber(startid, 16) local hi = tonumber(startid:sub(1, 2), 16)
local low = tonumber(startid:sub(3, 10), 16)
if shall_continue then if shall_continue then
print('Continue enrolling from last save') print('Continue enrolling from last save')
sid = readfile() hi, low = readfile()
else else
print('reset & starting enrolling from refresh') print('reset & starting enrolling from refresh')
end end
local template = 'EM4100 ID '..ac.green..'%010X'..ac.reset local template = 'EM4100 ID '..ac.green..'%02X%08X'..ac.reset
local curr = sid for i = low, low + 10000, 1 do
for i = sid, sid + 10000, 1 do
curr = i
print('') print('')
print( string.rep('--',20) ) print( string.rep('--',20) )
local msg = (template):format(curr) local msg = (template):format(hi, i)
local ans = utils.input(msg, 'y'):lower() local ans = utils.input(msg, 'y'):lower()
if ans == 'y' then if ans == 'y' then
core.console( ('lf em 410x clone --id %010X'):format(curr) ) core.console( ('lf em 410x clone --id %02X%08X'):format(hi, i) )
-- print ( ('lf em 410x clone --id %010X'):format(curr) ) -- print ( ('lf em 410x clone --id %02X%08X'):format(hi, i) )
else else
print(ac.red..'User aborted'..ac.reset) print(ac.red..'User aborted'..ac.reset)
low = i
break break
end end
end end
writefile(curr) writefile(hi, low)
print('enabling hints again') print('enabling hints again')
core.console('pref set hint --on') core.console('pref set hint --on')