]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/tracetest.lua
Merge pull request #192 from k02a/patch-1
[proxmark3-svn] / client / scripts / tracetest.lua
CommitLineData
81740aa5 1local cmds = require('commands')
2local getopt = require('getopt')
3local bin = require('bin')
4local utils = require('utils')
5local dumplib = require('html_dumplib')
6
7example =[[
8 1. script run tracetest
81740aa5 9]]
10author = "Iceman"
13d77ef9 11usage = "script run tracetest"
81740aa5 12desc =[[
13This script will load several traces files in ../traces/ folder and do
14"data load"
13d77ef9 15"lf search 1 u"
16
17The following tracefiles will be loaded:
18 em*.pm3
19 m*.pm3
81740aa5 20
21Arguments:
22 -h : this help
81740aa5 23]]
24
25local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
26local DEBUG = true -- the debug flag
27---
28-- A debug printout-function
29function 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
43end
44---
45-- This is only meant to be used when errors occur
46function oops(err)
47 print("ERROR: ",err)
48end
49---
50-- Usage help
51function help()
52 print(desc)
53 print("Example usage")
54 print(example)
55end
56--
57-- Exit message
58function ExitMsg(msg)
59 print( string.rep('--',20) )
60 print( string.rep('--',20) )
61 print(msg)
62 print()
63end
64
65
66local 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
13d77ef9 75 local write2File = false
81740aa5 76 local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
77
78 -- Arguments for the script
13d77ef9 79 for o, arg in getopt.getopt(args, 'h') do
81740aa5 80 if o == "h" then return help() end
81740aa5 81 end
13d77ef9 82
81740aa5 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
13d77ef9 101 local cmdLFSEARCH = "lf search 1 u"
81740aa5 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
81740aa5 123 print( string.rep('--',20) )
124
125end
126main(args)
Impressum, Datenschutz