CHG: minor layout and call fixes to e.lua (the test script for hooking up reveng1.30)

This commit is contained in:
iceman1001 2015-06-09 21:28:06 +02:00
parent 60e8657796
commit d352146782

View file

@ -1,15 +1,15 @@
local getopt = require('getopt') local getopt = require('getopt')
local utils = require('utils') local utils = require('utils')
example = "script calculates many checksums (CRC) over the provided hex input" example = "script calculates many different checksums (CRC) over the provided hex input"
author = "Iceman" author = "Iceman"
desc = desc =
[[ [[
This script calculates many checksums (CRS) over the provided hex input. This script calculates many checksums (CRC) over the provided hex input.
Arguments: Arguments:
-b data in hex -b data in hex
-w width of the CRC algorithm. <optional> defaults to all known CRC presets. -w bitwidth of the CRC family of algorithm. <optional> defaults to all known CRC presets.
Examples : Examples :
script run e -b 010203040506070809 script run e -b 010203040506070809
script run e -b 010203040506070809 -w 16 script run e -b 010203040506070809 -w 16
@ -45,25 +45,22 @@ function main(args)
-- Read the parameters -- Read the parameters
for o, a in getopt.getopt(args, 'hb:w:') do for o, a in getopt.getopt(args, 'hb:w:') do
if o == "h" then return help() end if o == "h" then return help() end
if o == "b" then data = utils.ConvertHexToa end if o == "b" then data = a end
if o == "w" then width = a end if o == "w" then width = a end
end end
print('Width of CRC: '..width..' bytes: '..data) print( string.rep('-',60) )
print('Bit width of CRC | '..width)
print('Bytes | '..data)
print('') print('')
print('Model','CRC', 'CRC_Reverse') print( ('%-20s| %-16s| %s'):format('Model','CRC', 'CRC reverse'))
print( string.rep('-',60) )
local lists = core.reveng_models(width) local lists = core.reveng_models(width)
for _,i in pairs(lists) do for _,i in pairs(lists) do
local one = core.reveng_runmodel(i, data, 0,0) local one = core.reveng_runmodel(i, data, false, 0)
local two = core.reveng_runmodel(i, data, 1,0) local two = core.reveng_runmodel(i, data, true, 0)
print( ('%-20s| %-16s| %s'):format(i, one, two) )
print(i, one, two)
end end
if 1 == 1 then
return
end
end end
main(args) main(args)