And now I have changed many legic commands input params...so you are up for a bumpy ride
]]>One of them is that the script uses outdated commands like
hf legic read 0x00 0x04
With the current implementation the user has to type in the returned bytes. Therefore I wanted to have a direct call to skip the user input.
]]>I’m currently try to refactor the Legic_clone.lua script so that it is working again with the current rrg repo (Issue 209).
I’ve got stuck with handling commands.
I want to get the first 4 bytes of a legic tag. On CLI I would call
hf legic rdmem 0 4
.
To get the bytes in LUA I use a function readlegicdata()
- read LEGIC data
local function readlegicdata( offset, length, iv )
-- Read data
local command = Command:newMIX{
cmd = cmds.CMD_HF_LEGIC_READER
, arg1 = offset
, arg2 = length
, arg3 = iv
, data = nil
}
local result, err = command:sendMIX()
if not result then return oops(err) end
print("DEBUG: "..type(result).." "..#result.." "..result.." "..('%02x'):format(result:byte(1))..('%02x'):format(result:byte(2))..('%02x'):format(result:byte(3))..('%02x'):format(result:byte(4)))
return result
end
When calling the function like
readbytes = readlegicdata(0, 4, 0x55)
result seems to be a string with 544 length. So I guess I have to
bin.unpack(????, result)
the result. However I have currently no clue of the structure of result.
Any hints, ideas how to get on here?
Thanks!
]]>