]> cvs.zerfleddert.de Git - proxmark3-svn/blobdiff - client/scripts/test_t55x7_psk.lua
lf t5 read plus lf demod adjustments
[proxmark3-svn] / client / scripts / test_t55x7_psk.lua
index 1b9640944b90aa7c9fab78b15513a196078edb04..766d853f9e5a7a413b68575c46caf2d47e96faeb 100644 (file)
@@ -2,15 +2,14 @@ local cmds = require('commands')
 local getopt = require('getopt')
 local bin = require('bin')
 local utils = require('utils')
 local getopt = require('getopt')
 local bin = require('bin')
 local utils = require('utils')
-local dumplib = require('html_dumplib')
 
 example =[[
 
 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"
 
 ]]
 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:
 desc =[[
 This script will program a T55x7 TAG with the configuration: block 0x00 data 0x00088040
 The outlined procedure is as following:
@@ -39,26 +38,34 @@ In all 12 individual test for the PSK demod
 
 Arguments:
        -h             : this help
 
 Arguments:
        -h             : this help
-       -o             : logfile name
 ]]
 
 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
 local DEBUG = true -- the debug flag
 ]]
 
 local TIMEOUT = 2000 -- Shouldn't take longer than 2 seconds
 local DEBUG = true -- the debug flag
-
---BLOCK 0 = 00088040
-local config1 = '0008'
-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',
+-- }
+
+-- --BLOCK 0 = 00 08 80 40 PSK
+                                               -- -----------
+                                                       --  08------- bitrate
+                                                                       -- 8----- modulation PSK1
+                                                                        -- 0---- PSK ClockRate
+                                                                                -- 40 max 2 blocks
+
 local procedurecmds = {
 local procedurecmds = {
-       [1] = '%s%s%s%s',
-       [2] = 'lf read',
+       [1] = '00%02X%X%X40',
+       [2] = 'lf t55xx detect',
        --[3] = '',
        --[3] = '',
-       [3] = 'data samples',
-       [4] = 'data pskdetectclock',
-       [5] = 'data psknrzrawdemod',
-       [6] = 'data pskindalademod',
+       [3] = 'lf t55xx info',
 }
 }
-
 --- 
 -- A debug printout-function
 function dbg(args)
 --- 
 -- A debug printout-function
 function dbg(args)
@@ -97,45 +104,35 @@ function ExitMsg(msg)
        print()
 end
 
        print()
 end
 
-function pskTest(modulation)
-       local y
-       for y = 0, 8, 4 do
-               for _ = 1, #procedurecmds do
+function test(modulation)
+       local bitrate
+       local clockrate
+       for bitrate = 0x0, 0x1d, 0x4 do
+       
+               for clockrate = 0,8,4 do
                        local cmd = procedurecmds[_]
                        local cmd = procedurecmds[_]
-                       
-                       if #cmd == 0 then  
-                       
+
+                       if #cmd == 0 then
+
                        elseif _ == 1 then
 
                                dbg("Writing to T55x7 TAG")
                        elseif _ == 1 then
 
                                dbg("Writing to T55x7 TAG")
-               
-                               local configdata = cmd:format( config1, modulation , y, config2)
-                               
-                               dbg( configdata)
+
+                               local config = cmd:format(bitrate, modulation, clockrate)
+                               dbg(('lf t55xx write 0 %s'):format(config))
                                
                                
-                               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)
                                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 )
                        end
                end
                        else
                                dbg(cmd)
                                core.console( cmd )
                        end
                end
-               core.clearCommandBuffer()       
        end
        print( string.rep('--',20) )
        end
        print( string.rep('--',20) )
-
 end
 
 local function main(args)
 end
 
 local function main(args)
@@ -143,31 +140,17 @@ local function main(args)
        print( string.rep('--',20) )
        print( string.rep('--',20) )
 
        print( string.rep('--',20) )
        print( string.rep('--',20) )
 
-       local outputTemplate = os.date("testpsk_%Y-%m-%d_%H%M%S")
-
        -- Arguments for the script
        -- 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 == "h" then return help() end
-               if o == "o" then outputTemplate = arg end               
        end
 
        core.clearCommandBuffer()
 
        end
 
        core.clearCommandBuffer()
 
-       pskTest(1)
-       pskTest(2)
-       pskTest(3)
-       pskTest(8)
+       test(1) --PSK1
+       -- test(2) --PSK2
+       -- test(3) --PSK3
        
        print( string.rep('--',20) )
 end
 main(args)
        
        print( string.rep('--',20) )
 end
 main(args)
-
--- Where it iterates over 
-  -- xxxx8xxx = PSK RF/2 with Manchester modulation
-  -- xxxx1xxx = PSK RF/2 with PSK1 modulation (phase change when input changes)
-  -- xxxx2xxx = PSK RF/2 with PSk2 modulation (phase change on bitclk if input high)
-  -- xxxx3xxx = PSK RF/2 with PSk3 modulation (phase change on rising edge of input)
-
-    -- XXXXX0XX = PSK RF/2
-    -- XXXXX4XX = PSK RF/4
-    -- XXXXX8XX = PSK RF/8
\ No newline at end of file
Impressum, Datenschutz