Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hex Checksum Assistance 1

Status
Not open for further replies.

DreXor

Programmer
Jun 17, 2003
2,224
US
i'm writing a small output generator to make hex data files to program eproms. i will be giving a web based interface to plug in the values desired to write to the chip ( in english standard 96 char set ) then push this to a formatted output in intel hex layout, i'm doing great on all aspects of it other than evaluating the checksum, i've never dealt with hex based checksums and it's messing my head up after stacking all these function calls to get all the formatting.

currently the place i think it would fall into place is the actual encoding of the string value to hex :

Code:
function Txt2Hex(StringVal)
    Txt2Hex = ""
    CheckSumVal = 0
    For ChrPos = 1 to Len(StringVal)
        CurrentLetter=Mid(StringVal,ChrPos,1)
        Txt2Hex = Txt2Hex & Hex(Asc(CurrentLetter))' & " "
        CheckSumVal = CheckSumVal + Asc(CurrentLetter)
    Next
    Txt2Hex = Txt2Hex & " " & Hex(CheckSumVal)
End function

i dont really have anything handy to validate if the checksum is correct but here's sample output :

GARAGE
47.41.52.41.47.45 1A7

the periods are just there for visual breaks

so in essence my question is, am i doing this correctly/getting the correct checksum... if n ot, how would i go about correcting it ?


[thumbsup2]DreX
aKa - Robert
 
AFAIK so far so good. Now take last two hex digits and calculate 2-complement ( 256 - (CheckSumVal mod 256) ).
 
EH? complement? uhm "nice caps" ? :)

lost me there vongrunt, this stuff is out of my area, but trying to do a friend in a pinch a favor.

[thumbsup2]DreX
aKa - Robert
 
koolies thanks man

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top