- local calc = calculateChecksum( utils.ConvertHexToBytes(testdata:sub(1,24)))
- print ('TESTDATA :: '..testdata)
- print ('DATA :: '..testdata:sub(1,24))
- print (('CHKSUM :: %X'):format(chksum))
- print (('CHKSUM CALC :: %X'):format(calc))
- print ('UPDATE CHKSUM :: '..updateChecksum(testdata))
-
-
+ local calc = calculateChecksum( utils.ConvertHexToBytes(testdata:sub(1,24)))
+ local isValid = false
+ local validStr = "FAIL"
+ if calc == chksum then
+ isValid = true
+ validStr = "OK"
+ end
+ local newtestdata = updateChecksum(testdata)
+ local revalidated = "FAIL"
+ if newtestdata == testdata then
+ revalidated = "OK"
+ end
+ print ('TESTDATA :: '..testdata)
+ print ('DATA :: '..testdata:sub(1,24))
+ print (('VALID CHKSUM :: %s'):format(validStr ))
+ print (('UPDATE CHKSUM :: %s'):format(revalidated))