ADD: added the crc8legic to Lua. call it with core.crc8legic
also a helper function to take a hexstring and calc the crc on it, was added inside utils.lua
Call it inside a lua-script like this:
local utils = require('utils')
local data = '01020304'
local crc = utils.Crc8Legic(data)
print (uid, ('%02x'):format(crc))
This commit is contained in:
@@ -82,6 +82,20 @@ local Utils =
|
||||
return nil
|
||||
end,
|
||||
|
||||
------------ CRC-16 ccitt checksums
|
||||
-- Takes a hex string and calculates a crc16
|
||||
Crc8Legic = function(s)
|
||||
if s == nil then return nil end
|
||||
if #s == 0 then return nil end
|
||||
if type(s) == 'string' then
|
||||
local utils = require('utils')
|
||||
local asc = utils.ConvertHexToAscii(s)
|
||||
local hash = core.crc8legic(asc)
|
||||
return hash
|
||||
end
|
||||
return nil
|
||||
end,
|
||||
|
||||
------------ CRC-16 ccitt checksums
|
||||
-- Takes a hex string and calculates a crc16
|
||||
Crc16 = function(s)
|
||||
@@ -96,6 +110,7 @@ local Utils =
|
||||
return nil
|
||||
end,
|
||||
|
||||
|
||||
------------ CRC-64 ecma checksums
|
||||
-- Takes a hex string and calculates a crc64 ecma
|
||||
Crc64 = function(s)
|
||||
|
||||
Reference in New Issue
Block a user