maur keys
[RRG-proxmark3.git] / client / luascripts / tests / hf_read.lua
blob7c70e37d9eca8258d23247935a21fa9664c440a2
1 local reader = require('hf_reader')
2 local getopt = require('getopt')
3 local ansicolors = require('ansicolors')
5 copyright = ''
6 author = ''
7 version = 'v1.0.1'
8 desc = [[
9 This script tries to detect a HF card. Just like 'hf search' does but this is experimental
11 example = [[
12 1. script run hf_read
14 usage = [[
15 script run hf_read
17 arguments = [[
18 -h - this help
20 ---
21 -- This is only meant to be used when errors occur
22 local function dbg(args)
23 if not DEBUG then return end
24 if type(args) == 'table' then
25 local i = 1
26 while args[i] do
27 dbg(args[i])
28 i = i+1
29 end
30 else
31 print('###', args)
32 end
33 end
34 ---
35 -- This is only meant to be used when errors occur
36 local function oops(err)
37 print('ERROR:', err)
38 core.clearCommandBuffer()
39 return nil, err
40 end
41 ---
42 -- Usage help
43 local function help()
44 print(copyright)
45 print(author)
46 print(version)
47 print(desc)
48 print(ansicolors.cyan..'Usage'..ansicolors.reset)
49 print(usage)
50 print(ansicolors.cyan..'Arguments'..ansicolors.reset)
51 print(arguments)
52 print(ansicolors.cyan..'Example usage'..ansicolors.reset)
53 print(example)
54 end
55 ---
57 local function main(args)
58 -- Arguments for the script
59 for o, a in getopt.getopt(args, 'h') do
60 if o == 'h' then return help() end
61 end
63 print("WORK IN PROGRESS - not expected to be functional yet")
64 info, err = reader.waitForTag()
66 if err then
67 print(err)
68 return
69 end
70 local k,v
71 print("Tag info")
72 for k,v in pairs(info) do
73 print(string.format(" %s : %s", tostring(k), tostring(v)))
74 end
75 return
76 end
78 main(args)