ISO14A_APPEND_CRC = 0x20,
ISO14A_SET_TIMEOUT = 0x40,
ISO14A_NO_SELECT = 0x80,
- ISO14A_TOPAZMODE = 0x100
+ ISO14A_TOPAZMODE = 0x100,
+ ISO14A_NO_RATS = 0x200
}
local ISO14443a_TYPES = {}
-- This function does a connect and retrieves som einfo
-- @param dont_disconnect - if true, does not disable the field
+-- @param no_rats - if true, skips ISO14443-4 select (RATS)
-- @return if successfull: an table containing card info
-- @return if unsuccessfull : nil, error
-local function read14443a(dont_disconnect)
+local function read14443a(dont_disconnect, no_rats)
local command, result, info, err, data
command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
if dont_disconnect then
command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_DISCONNECT
end
+ if no_rats then
+ command.arg1 = command.arg1 + ISO14A_COMMAND.ISO14A_NO_RATS
+ end
local result,err = sendToDevice(command)
if result then
local count,cmd,arg0,arg1,arg2 = bin.unpack('LLLL',result)
-p stay connected - dont inactivate the field
-x <payload> Data to send (NO SPACES!)
-d Debug flag
+ -t Topaz mode
+ -3 Skip ISO14443-4 select
Examples :
print(example)
end
+
---
-- The main entry point
function main(args)
local stayconnected = false
local payload = nil
local doconnect = true
+ local topaz_mode = false
+ local no_rats = false
-- Read the parameters
- for o, a in getopt.getopt(args, 'corcpx:') do
+ for o, a in getopt.getopt(args, 'corcpxt3:') do
if o == "o" then doconnect = false end
if o == "r" then ignore_response = true end
if o == "c" then appendcrc = true end
if o == "p" then stayconnected = true end
if o == "x" then payload = a end
if o == "d" then DEBUG = true end
+ if o == "t" then topaz_mode = true end
+ if o == "3" then no_rats = true end
end
-- First of all, connect
dbg("doconnect")
-- We reuse the connect functionality from a
-- common library
- info, err = lib14a.read1443a(true)
+ info, err = lib14a.read1443a(true, no_rats)
if err then return oops(err) end
print(("Connected to card, uid = %s"):format(info.uid))
end
-
function sendRaw(rawdata, options)
print(">> ", rawdata)
local flags = lib14a.ISO14A_COMMAND.ISO14A_NO_DISCONNECT + lib14a.ISO14A_COMMAND.ISO14A_RAW
+ if topaz_mode == true then flags = flags + lib14a.ISO14A_COMMAND.ISO14A_TOPAZMODE end
local command = Command:new{cmd = cmds.CMD_READER_ISO_14443a,
arg1 = flags, -- Send raw
-- GET TAG UID
- result, err = lib14a.read1443a(false)
+ result, err = lib14a.read1443a(false, true)
if not result then
return oops(err)
end
--\r
-- Read information from a card\r
function GetCardInfo()\r
- result, err = lib14a.read1443a(false)\r
+ result, err = lib14a.read1443a(false, true)\r
if not result then\r
print(err)\r
return\r
print(desc);
- result, err = reader.read1443a()
+ result, err = reader.read1443a(false, true)
if not result then
print(err)
return
-- @return if unsuccessfull : nil, error
function wait_for_mifare()
while not core.ukbhit() do
- res, err = reader.read1443a()
+ res, err = reader.read1443a(false, true)
if res then return res end
-- err means that there was no response from card
end
-- find tag
- result, err = lib14a.read1443a(false)
+ result, err = lib14a.read1443a(false, true)
if not result then return oops(err) end
-- load keys
local cmdSetDbgOff = "hf mf dbg 0"
core.console( cmdSetDbgOff)
- result, err = lib14a.read1443a(false)
+ result, err = lib14a.read1443a(false, true)
if not result then
return oops(err)
end