Skip to content

Commit

Permalink
fix: script run legic_buffer2card - correct params for write command
Browse files Browse the repository at this point in the history
  • Loading branch information
iceman1001 committed May 7, 2019
1 parent a5f19cd commit 5b087a0
Showing 1 changed file with 26 additions and 17 deletions.
43 changes: 26 additions & 17 deletions client/scripts/legic_buffer2card.lua
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
local utils = require('utils')
local getopt = require('getopt')
-- this script writes bytes 8 to 256 on the Legic MIM256
example = "Script writes to Legic Prime Tag from position 0x07 until 0xFF with the value 0x01"
author = "Mosci"

copyright = ''
author = 'Mosci'
version = 'v1.0.1'
desc =
[[
This is a script which writes value 0x01 to bytes from position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024)
(created with 'hf legic save my_dump.hex')
This is a script which writes value 0x01 to bytes from position 0x07 until 0xFF on a Legic Prime Tag (MIM256 or MIM1024) -- (created with 'hf legic save my_dump.hex') --
]]
example = [[
script run legic_buffer2card
]]
usage = [[
script run legic_buffer2card -h
optional arguments :
Arguments
-h - Help text
Examples :
script run legic_buffer2card
]]

local utils = require('utils')
local getopt = require('getopt')
---
-- This is only meant to be used when errors occur
function oops(err)
print("ERROR: ",err)
local function oops(err)
print('ERROR:', err)
core.clearCommandBuffer()
return nil, err
end
end
---
-- Usage help
function help()
local function help()
print(copyright)
print(author)
print(version)
print(desc)
print("Example usage")
print('Example usage')
print(example)
print(usage)
end
--
-- simple loop-write from 0x07 to 0xff
function main()

-- parse arguments for the script
for o, a in getopt.getopt(args, 'h') do
if o == "h" then return help() end
if o == 'h' then return help() end
end

local cmd = ''
local i
for i = 7, 255 do
cmd = ('hf legic write 0x%02x 0x01'):format(i)
cmd = ('hf legic write o %02x d 01'):format(i)
print(cmd)
core.clearCommandBuffer()
core.console(cmd)
Expand Down

0 comments on commit 5b087a0

Please sign in to comment.