]> git.zerfleddert.de Git - proxmark3-svn/blob - client/scripts/tracetest.lua
fix lf file includes to include own .h
[proxmark3-svn] / client / scripts / tracetest.lua
1 local cmds = require('commands')
2 local getopt = require('getopt')
3 local bin = require('bin')
4 local utils = require('utils')
5 local dumplib = require('html_dumplib')
6
7 example =[[
8 1. script run tracetest
9 ]]
10 author = "Iceman"
11 usage = "script run tracetest"
12 desc =[[
13 This script will load several traces files in ../traces/ folder and do
14 "data load"
15 "lf search 1 u"
16
17 The following tracefiles will be loaded:
18 em*.pm3
19 m*.pm3
20
21 Arguments:
22 -h : this help
23 ]]
24
25 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
26 local DEBUG = true -- the debug flag
27 ---
28 -- A debug printout-function
29 function dbg(args)
30 if not DEBUG then
31 return
32 end
33
34 if type(args) == "table" then
35 local i = 1
36 while result[i] do
37 dbg(result[i])
38 i = i+1
39 end
40 else
41 print("###", args)
42 end
43 end
44 ---
45 -- This is only meant to be used when errors occur
46 function oops(err)
47 print("ERROR: ",err)
48 end
49 ---
50 -- Usage help
51 function help()
52 print(desc)
53 print("Example usage")
54 print(example)
55 end
56 --
57 -- Exit message
58 function ExitMsg(msg)
59 print( string.rep('--',20) )
60 print( string.rep('--',20) )
61 print(msg)
62 print()
63 end
64
65
66 local function main(args)
67
68 print( string.rep('--',20) )
69 print( string.rep('--',20) )
70
71 local cmdDataLoad = 'data load %s';
72 local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
73 local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
74
75 local write2File = false
76 local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
77
78 -- Arguments for the script
79 for o, arg in getopt.getopt(args, 'h') do
80 if o == "h" then return help() end
81 end
82
83 core.clearCommandBuffer()
84
85 local files = {}
86
87 -- Find a set of traces staring with EM
88 local p = assert( io.popen(tracesEM))
89 for file in p:lines() do
90 table.insert(files, file)
91 end
92 p.close();
93
94 -- Find a set of traces staring with MOD
95 p = assert( io.popen(tracesMOD) )
96 for file in p:lines() do
97 table.insert(files, file)
98 end
99 p.close();
100
101 local cmdLFSEARCH = "lf search 1 u"
102
103 -- main loop
104 io.write('Starting to test traces > ')
105 for _,file in pairs(files) do
106
107 local x = "data load "..file
108 dbg(x)
109 core.console(x)
110
111 dbg(cmdLFSEARCH)
112 core.console(cmdLFSEARCH)
113
114 core.clearCommandBuffer()
115
116 if core.ukbhit() then
117 print("aborted by user")
118 break
119 end
120 end
121 io.write('\n')
122
123 print( string.rep('--',20) )
124
125 end
126 main(args)
Impressum, Datenschutz