]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
ADD: new tests for the T55XX commands.
authoriceman1001 <iceman@iuse.se>
Wed, 18 Mar 2015 16:32:43 +0000 (17:32 +0100)
committericeman1001 <iceman@iuse.se>
Wed, 18 Mar 2015 16:32:43 +0000 (17:32 +0100)
CHG:  minor output messages in cmdlft55xx.c

client/cmdlft55xx.c
client/scripts/test_t55x7_ask.lua [new file with mode: 0644]
client/scripts/test_t55x7_bi.lua [new file with mode: 0644]
client/scripts/test_t55x7_fsk.lua [new file with mode: 0644]
client/scripts/test_t55x7_psk.lua
client/scripts/tracetest.lua

index bd4026381f8e237150dba41dce19261840ed05a1..61758bde01e576c632dafcce0fe9c23f3af8e9a6 100644 (file)
@@ -276,8 +276,8 @@ int CmdT55xxDetect(const char *Cmd){
        if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') \r
                return usage_t55xx_detect();\r
 \r
-       if ( strlen(Cmd)==0)\r
-               AquireData(CONFIGURATION_BLOCK);\r
+       if (strlen(Cmd)==0)\r
+               AquireData( CONFIGURATION_BLOCK );\r
        \r
        if ( !tryDetectModulation() )\r
                PrintAndLog("Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");\r
@@ -534,7 +534,6 @@ int special(const char *Cmd) {
                //PrintAndLog("[%02d] 0x%08X  %s %s",j , blockData, sprint_bin(bits,32), indicate);     \r
                PrintAndLog("[%02d] 0x%08X  %s",j , blockData, sprint_bin(bits,32));    \r
        }\r
-       \r
        return 0;\r
 }\r
 \r
@@ -566,16 +565,14 @@ int CmdT55xxWriteBlock(const char *Cmd)
        }\r
 \r
        if (block > 7) {\r
-               PrintAndLog("Block must be between 0 and 7");\r
+               PrintAndLog("Block number must be between 0 and 7");\r
                return 1;\r
        }\r
        \r
        UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r
        c.d.asBytes[0] = 0x0; \r
 \r
-       PrintAndLog("Writing to T55x7");\r
-       PrintAndLog("block : %d", block);\r
-       PrintAndLog("data  : 0x%08X", data);\r
+       PrintAndLog("Writing to block: %d  data: 0x%08X", block, data);\r
 \r
        //Password mode\r
        if (res == 3) {\r
@@ -594,9 +591,8 @@ int CmdT55xxReadTrace(const char *Cmd)
        if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') \r
                return usage_t55xx_trace();\r
 \r
-       if ( strlen(Cmd)==0){\r
+       if (strlen(Cmd)==0)\r
                AquireData( TRACE_BLOCK );\r
-       }\r
        \r
        DecodeT55xxBlock();\r
 \r
diff --git a/client/scripts/test_t55x7_ask.lua b/client/scripts/test_t55x7_ask.lua
new file mode 100644 (file)
index 0000000..569d426
--- /dev/null
@@ -0,0 +1,139 @@
+local cmds = require('commands')
+local getopt = require('getopt')
+local bin = require('bin')
+local utils = require('utils')
+
+local format=string.format
+local floor=math.floor
+
+example =[[
+       1. script run test_t55x7_ask
+]]
+author = "Iceman"
+usage = "script run test_t55x7_ask"
+desc =[[
+This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
+The outlined procedure is as following:
+
+--ASK 
+       00 00 80 40
+--           max 2
+--        manchester
+--     bit rate
+"lf t55xx write 0 00008040"
+"lf t55xx detect"
+"lf t55xx info"
+
+Loop:
+       change the configuretion block 0 with:
+    -xx 00 xxxx = RF/8 
+    -xx 04 xxxx = RF/16
+       -xx 08 xxxx = RF/32
+       -xx 0C xxxx = RF/40
+       -xx 10 xxxx = RF/50
+       -xx 14 xxxx = RF/64
+       -xx 18 xxxx = RF/100
+       -xx 1C xxxx = RF/128
+
+
+testsuit for the ASK/MANCHESTER demod
+
+Arguments:
+       -h             : this help
+]]
+
+local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
+local DEBUG = true -- the debug flag
+
+--BLOCK 0 = 00008040 ASK / MAN
+local config1 = '00'
+local config2 = '8040'
+
+local procedurecmds = {
+       [1] = '%s%02X%s',
+       [2] = 'lf t55xx detect',
+       [3] = 'lf t55xx info',
+}
+--- 
+-- A debug printout-function
+function dbg(args)
+       if not DEBUG then
+               return
+       end
+       
+    if type(args) == "table" then
+               local i = 1
+               while args[i] do
+                       dbg(args[i])
+                       i = i+1
+               end
+       else
+               print("###", args)
+       end     
+end    
+--- 
+-- This is only meant to be used when errors occur
+function oops(err)
+       print("ERROR: ",err)
+end
+--- 
+-- Usage help
+function help()
+       print(desc)
+       print("Example usage")
+       print(example)
+end
+--
+-- Exit message
+function ExitMsg(msg)
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+       print(msg)
+       print()
+end
+
+function test()
+       local y
+       for y = 0x0, 0x1d, 0x4 do
+               for _ = 1, #procedurecmds do
+                       local pcmd = procedurecmds[_]
+                       
+                       if #pcmd == 0 then  
+                       
+                       elseif _ == 1 then
+
+                               local config = pcmd:format(config1, y, config2)
+                               dbg(('lf t55xx write 0 %s'):format(config))                     
+                               config = tonumber(config,16) 
+                               
+                               local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}                   
+                               local err = core.SendCommand(writecmd:getBytes())
+                               if err then return oops(err) end
+                               local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+
+                       else
+                               dbg(pcmd)
+                               core.console( pcmd )
+                       end                     
+               end
+               core.clearCommandBuffer()       
+       end
+       print( string.rep('--',20) )
+end
+
+local function main(args)
+
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+
+       -- Arguments for the script
+       for o, arg in getopt.getopt(args, 'h') do
+               if o == "h" then return help() end
+       end
+
+       core.clearCommandBuffer()
+       test()
+       print( string.rep('--',20) )
+end
+main(args)
\ No newline at end of file
diff --git a/client/scripts/test_t55x7_bi.lua b/client/scripts/test_t55x7_bi.lua
new file mode 100644 (file)
index 0000000..91445d4
--- /dev/null
@@ -0,0 +1,132 @@
+local cmds = require('commands')
+local getopt = require('getopt')
+local bin = require('bin')
+local utils = require('utils')
+
+example =[[
+       1. script run test_t55x7_bi
+]]
+author = "Iceman"
+usage = "script run test_t55x7_bi"
+desc =[[
+This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00010040
+The outlined procedure is as following:
+
+--BIPHASE 00010040
+--
+
+"lf t55xx write 0 00010040"
+"lf t55xx detect"
+"lf t55xx info"
+
+Loop:
+       change the configuretion block 0 with:
+    -xx01xxxx = RF/8 
+    -xx05xxxx = RF/16
+       -xx09xxxx = RF/32
+       -xx0Dxxxx = RF/40
+       -xx11xxxx = RF/50
+       -xx15xxxx = RF/64
+       -xx19xxxx = RF/100
+       -xx1Dxxxx = RF/128
+
+
+testsuit for the BIPHASE demod
+
+Arguments:
+       -h             : this help
+]]
+
+local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
+local DEBUG = true -- the debug flag
+
+--BLOCK 0 = 00010040 BIPHASE
+local config1 = '00'
+local config2 = '0040'
+
+local procedurecmds = {
+       [1] = '%s%02X%s',
+       [2] = 'lf t55xx detect',
+       [3] = 'lf t55xx info',
+}
+--- 
+-- A debug printout-function
+function dbg(args)
+       if not DEBUG then
+               return
+       end
+       
+    if type(args) == "table" then
+               local i = 1
+               while args[i] do
+                       dbg(args[i])
+                       i = i+1
+               end
+       else
+               print("###", args)
+       end     
+end    
+--- 
+-- This is only meant to be used when errors occur
+function oops(err)
+       print("ERROR: ",err)
+end
+--- 
+-- Usage help
+function help()
+       print(desc)
+       print("Example usage")
+       print(example)
+end
+--
+-- Exit message
+function ExitMsg(msg)
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+       print(msg)
+       print()
+end
+
+function test()
+       local y
+       for y = 1, 0x1D, 4 do
+               for _ = 1, #procedurecmds do
+                       local pcmd = procedurecmds[_]
+                       
+                       if #pcmd == 0 then  
+                       
+                       elseif _ == 1 then
+
+                               local config = pcmd:format(config1, y, config2)
+                               dbg(('lf t55xx write 0 %s'):format(config))
+                               
+                               local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
+                               local err = core.SendCommand(writecmd:getBytes())
+                               if err then return oops(err) end
+                               local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+                       else
+                               dbg(pcmd)
+                               core.console( pcmd )
+                       end
+               end
+               core.clearCommandBuffer()       
+       end
+       print( string.rep('--',20) )
+
+end
+
+local function main(args)
+
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+
+       -- Arguments for the script
+       for o, arg in getopt.getopt(args, 'h') do
+               if o == "h" then return help() end
+       end
+
+       core.clearCommandBuffer()
+       test()
+       print( string.rep('--',20) )
+end
+main(args)
\ No newline at end of file
diff --git a/client/scripts/test_t55x7_fsk.lua b/client/scripts/test_t55x7_fsk.lua
new file mode 100644 (file)
index 0000000..f42dd14
--- /dev/null
@@ -0,0 +1,139 @@
+local cmds = require('commands')
+local getopt = require('getopt')
+local bin = require('bin')
+local utils = require('utils')
+
+example =[[
+       1. script run test_t55x7_fsk
+]]
+author = "Iceman"
+usage = "script run test_t55x7_fsk"
+desc =[[
+This script will program a T55x7 TAG with the configuration: block 0x00 data 0x000100
+The outlined procedure is as following:
+
+--ASK 
+       00 00 80 40
+--           max 2 blocks
+--        FSK1
+--     bit rate
+"lf t55xx write 0 00007040"
+"lf t55xx detect"
+"lf t55xx info"
+
+Loop:
+       change the configuretion block 0 with:
+    -xx 00 xxxx = RF/8 
+    -xx 04 xxxx = RF/16
+       -xx 08 xxxx = RF/32
+       -xx 0C xxxx = RF/40
+       -xx 10 xxxx = RF/50
+       -xx 14 xxxx = RF/64
+       -xx 18 xxxx = RF/100
+       -xx 1C xxxx = RF/128
+
+
+testsuit for the ASK/MANCHESTER demod
+
+Arguments:
+       -h             : this help
+]]
+
+local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
+local DEBUG = true -- the debug flag
+
+--BLOCK 0 = 00008040 FSK
+local config1 = '00'
+local config2 = '040'
+
+local procedurecmds = {
+       [1] = '%s%02X%X%s',
+       [2] = 'lf t55xx detect',
+       [3] = 'lf t55xx info',
+}
+--- 
+-- A debug printout-function
+function dbg(args)
+       if not DEBUG then
+               return
+       end
+       
+    if type(args) == "table" then
+               local i = 1
+               while args[i] do
+                       dbg(args[i])
+                       i = i+1
+               end
+       else
+               print("###", args)
+       end     
+end    
+--- 
+-- This is only meant to be used when errors occur
+function oops(err)
+       print("ERROR: ",err)
+end
+--- 
+-- Usage help
+function help()
+       print(desc)
+       print("Example usage")
+       print(example)
+end
+--
+-- Exit message
+function ExitMsg(msg)
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+       print(msg)
+       print()
+end
+
+function test(modulation)
+       local y
+       for y = 0x0, 0x1d, 0x4 do
+               for _ = 1, #procedurecmds do
+                       local pcmd = procedurecmds[_]
+                       
+                       if #pcmd == 0 then  
+                       
+                       elseif _ == 1 then
+
+                               local config = pcmd:format(config1, y, modulation, config2)
+                               dbg(('lf t55xx write 0 %s'):format(config))
+                               
+                               config = tonumber(config,16) 
+                               local writecmd = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config}
+                               local err = core.SendCommand(writecmd:getBytes())
+                               if err then return oops(err) end
+                               local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
+
+                       else
+                               dbg(pcmd)
+                               core.console( pcmd )
+                       end                     
+               end
+               core.clearCommandBuffer()       
+       end
+       print( string.rep('--',20) )
+end
+
+local function main(args)
+
+       print( string.rep('--',20) )
+       print( string.rep('--',20) )
+
+       -- Arguments for the script
+       for o, arg in getopt.getopt(args, 'h') do
+               if o == "h" then return help() end
+       end
+
+       core.clearCommandBuffer()
+       test(4)
+       test(5)
+       test(6)
+       test(7)
+       print( string.rep('--',20) )
+end
+main(args)
\ No newline at end of file
index 1b9640944b90aa7c9fab78b15513a196078edb04..2909ff8352b2bb0f54ada23ff740e99035e138b8 100644 (file)
@@ -2,15 +2,14 @@ local cmds = require('commands')
 local getopt = require('getopt')
 local bin = require('bin')
 local utils = require('utils')
-local dumplib = require('html_dumplib')
 
 example =[[
-       1. script run tracetest
-       2. script run tracetest -o 
+       1. script run test_t55x7_psk
+       2. script run test_t55x7_psk -o 
 
 ]]
 author = "Iceman"
-usage = "script run test_t55x7_psk -o <filename>"
+usage = "script run test_t55x7_psk"
 desc =[[
 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
 The outlined procedure is as following:
@@ -39,26 +38,31 @@ In all 12 individual test for the PSK demod
 
 Arguments:
        -h             : this help
-       -o             : logfile name
 ]]
 
 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
 local DEBUG = true -- the debug flag
 
---BLOCK 0 = 00088040
-local config1 = '0008'
+--BLOCK 0 = 00088040 PSK
+local config1 = '0014'
 local config2 = '40'
        
+-- local procedurecmds = {
+       -- [1] = '%s%s%s%s',
+       -- [2] = 'lf read',
+       -- --[3] = '',
+       -- [3] = 'data samples',
+       -- [4] = 'data pskdetectclock',
+       -- [5] = 'data psknrzrawdemod',
+       -- [6] = 'data pskindalademod',
+-- }
+
 local procedurecmds = {
        [1] = '%s%s%s%s',
-       [2] = 'lf read',
+       [2] = 'lf t55xx detect',
        --[3] = '',
-       [3] = 'data samples',
-       [4] = 'data pskdetectclock',
-       [5] = 'data psknrzrawdemod',
-       [6] = 'data pskindalademod',
+       [3] = 'lf t55xx info',
 }
-
 --- 
 -- A debug printout-function
 function dbg(args)
@@ -97,7 +101,7 @@ function ExitMsg(msg)
        print()
 end
 
-function pskTest(modulation)
+function test(modulation)
        local y
        for y = 0, 8, 4 do
                for _ = 1, #procedurecmds do
@@ -109,24 +113,14 @@ function pskTest(modulation)
 
                                dbg("Writing to T55x7 TAG")
                
-                               local configdata = cmd:format( config1, modulation , y, config2)
+                               local config = cmd:format( config1, modulation , y, config2)                            
+                               dbg(('lf t55xx write 0 %s'):format(config))
                                
-                               dbg( configdata)
-                               
-                               local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = configdata ,arg2 = 0, arg3 = 0}
+                               config = tonumber(config,16) 
+                               local writecommand = Command:new{cmd = cmds.CMD_T55XX_WRITE_BLOCK, arg1 = config ,arg2 = 0, arg3 = 0}
                                local err = core.SendCommand(writecommand:getBytes())
                                if err then return oops(err) end
                                local response = core.WaitForResponseTimeout(cmds.CMD_ACK,TIMEOUT)
-
-                               if response then
-                                       local count,cmd,arg0 = bin.unpack('LL',response)
-                                       if(arg0==1) then
-                                               dbg("Writing success")
-                                       else
-                                               return nil, "Couldn't read block.." 
-                                       end
-                               end
-
                        else
                                dbg(cmd)
                                core.console( cmd )
@@ -135,7 +129,6 @@ function pskTest(modulation)
                core.clearCommandBuffer()       
        end
        print( string.rep('--',20) )
-
 end
 
 local function main(args)
@@ -143,20 +136,17 @@ local function main(args)
        print( string.rep('--',20) )
        print( string.rep('--',20) )
 
-       local outputTemplate = os.date("testpsk_%Y-%m-%d_%H%M%S")
-
        -- Arguments for the script
-       for o, arg in getopt.getopt(args, 'ho:') do
+       for o, arg in getopt.getopt(args, 'h') do
                if o == "h" then return help() end
-               if o == "o" then outputTemplate = arg end               
        end
 
        core.clearCommandBuffer()
 
-       pskTest(1)
-       pskTest(2)
-       pskTest(3)
-       pskTest(8)
+       test(1)
+       test(2)
+       test(3)
+       test(8)
        
        print( string.rep('--',20) )
 end
index e4a9215cb0a74bb0c877c0f636c4097a1031c721..ae4055aed40a9a6c891a42b62af7cb42369f2fcc 100644 (file)
@@ -6,19 +6,20 @@ local dumplib = require('html_dumplib')
 
 example =[[
        1. script run tracetest
-       2. script run tracetest -o 
-
 ]]
 author = "Iceman"
-usage = "script run tracetest -o <filename>"
+usage = "script run tracetest"
 desc =[[
 This script will load several traces files in ../traces/ folder and do 
 "data load"
-"lf search" 
+"lf search 1 u" 
+
+The following tracefiles will be loaded:  
+   em*.pm3
+   m*.pm3
 
 Arguments:
        -h             : this help
-       -o             : logfile name
 ]]
 
 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
@@ -71,14 +72,14 @@ local function main(args)
        local tracesEM = "find '../traces/' -iname 'em*.pm3' -type f"
        local tracesMOD = "find '../traces/' -iname 'm*.pm3' -type f"
 
+       local write2File = false
        local outputTemplate = os.date("testtest_%Y-%m-%d_%H%M%S")
 
        -- Arguments for the script
-       for o, arg in getopt.getopt(args, 'ho:') do
+       for o, arg in getopt.getopt(args, 'h') do
                if o == "h" then return help() end              
-               if o == "o" then outputTemplate = arg end               
        end
-
+       
        core.clearCommandBuffer()
        
        local files = {}
@@ -97,7 +98,7 @@ local function main(args)
        end
        p.close();
        
-       local cmdLFSEARCH = "lf search 1" 
+       local cmdLFSEARCH = "lf search 1 u
        
        -- main loop
        io.write('Starting to test traces > ')
@@ -119,13 +120,6 @@ local function main(args)
        end
        io.write('\n')
 
-       -- Write dump to files
-       if not DEBUG then
-               local bar = dumplib.SaveAsText(emldata, outputTemplate..'.txt')
-               print(("Wrote output to:  %s"):format(bar))
-       end
-
-       -- Show info 
        print( string.rep('--',20) )
 
 end
Impressum, Datenschutz