View Full Version : LUA Calculating Hex Checksum
johnp
April 30th, 2007, 07:58 AM
Any ideas on how I can use LUA to calculate a hex checksum on a string of bytes?
Thanks.
Rob H
April 30th, 2007, 09:41 AM
We need more information - what sort of checksum? Do you have an algorithm for the checksum computation or a bit of existing program code in another language?
johnp
April 30th, 2007, 09:55 AM
Just need to do a simple add on a series of 14 hex byte result should be 16 bit word
Format is as follows:
Byte 0 0xFFh
Byte 1 0xAAh
Byte 2 0x00h
Byte 3 0x01h
Byte 4 0x82h
Byte 5 0x09h
Byte 6 0x00h - 0x3Bh
Byte 7 0x00h - 0x17h
Byte 8 0x00h - 0xFFh
Byte 9 0x00h - 0xFFh
Byte 10 0x00h - 0xFFh
Byte 11 0x00h - 0xFFh
Byte 12 0x00h - 0xFFh
Byte 13 0x00h - 0xFFh
Byte 14 0x00h - 0xFFh
Byte 15 Hi Byte of Checksum 0x??h
Byte 16 Lo Byte of Checksum 0x??h
So if I manually calculated the above, with alll variables set to 0x00h the resultant sum would be 235 which would make byte 15 0x02h and byte 16 0x35h
So if I could just figure out how to convert a byte from hex to decimal then add it up and then covert it back to hex, or alternatively do hex addition, I would be set, but I just can't figure that out...
Thanks as always.
Rob H
April 30th, 2007, 01:31 PM
If you read the Girder help file - Lua library reference\math library - near the end you'll find various conversion functions.
johnp
April 30th, 2007, 01:59 PM
Many Thanks.
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.