Start fixing legic.lua ! Now loads dumps fine

This commit is contained in:
BOURDY Romain 2017-05-17 18:52:30 +02:00
parent 7b8cbd38a8
commit bf413f1b87

View file

@ -296,6 +296,7 @@ function file_check(file_name)
if file_found==nil then
return false
else
file_found:close()
return true
end
end
@ -339,14 +340,13 @@ end
function getInputBytes(infile)
local line
local bytes = {}
local fhi,err = io.open(infile)
local fhi,err = io.open(infile,"rb")
if err then oops("faild to read from file ".. infile); return false; end
while true do
line = fhi:read()
if line == nil then break end
for byte in line:gmatch("%w+") do
table.insert(bytes, byte)
end
file_data = fhi:read("*a");
for i = 1, #file_data
do
bytes[i] = string.format("%x",file_data:byte(i))
end
fhi:close()
if (bytes[7]=='00') then return false end
@ -507,8 +507,8 @@ function readFromPM3()
local tag, bytes, infile
infile="legic.temp"
core.console("hf legic reader")
core.console("hf legic save "..infile)
tag=readFile(infile)
core.console("hf legic esave "..infile)
tag=readFile(infile..".bin")
return tag
end