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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to checksum with Aspect 1

Status
Not open for further replies.

polluxtech

Programmer
Dec 14, 2009
15
CN
Hi friends:
I have a problem, need help.
I capture data to a binary file,and have to zero checksum one sector of data.

The binary file like this:

00 01 02 03 04 05 06 07
00H: 0xa0 0x12 0x13 0xf0 0xf1 0xc2 0xc4 0xea
08H: 0xab 0x32 0x13 0xf0 0xb1 0xc5 0xa7 0x5a
10H: 0xb0 0x12 0x08 0xa0 0xf1 0xc2 0xc6 0xe1
18H: 0xa0 0x12 0x23 0xd0 0xf1 0xc2 0xc4 0x34
20H: 0xc4 0x12 0x13 0xe0 0xf1 0xc3 0xe4 0x52

My job is to zero checksum bytes data from offset 04H to 18H. It means that I need to check if 0xf1+0xc2+0xea+...+0xa0=0, if not I have to change the last byte's value(offset 18H) to make the check sum to equal zero.

But I find the the aspect does not support unsigned byte data type. I confused. Need help. Thanks in advanced.

 
anybody help?

Is there any data type like char to handle byte data?

My work is that to read data from binary file byte by byte, i know using fgetc function to get one byte data, but how to do the zero checksum? help,please. Thanks
 
I seem to recall there was someone with a similar question (might have been trying to use a different polynomial than what Procomm supports in the crc16 command), you might try searching the forum for that thread to see if he had a solution for doing byte operations. It's been a long time since I've done so, and never in Procomm to the best of my recollection. If you have existing code in another language or pseudocode to implement this, you might look at the ASPECT Operator Table topic in the help file and see if that offers any help.

 
hi knob:
thanks for your prompt reply.
but i can not find any useful information about crc16 and byte operations. would you give me some hints.
Thanks.
 
thanks, knob
I have got another way to do this. :)

my piece of code:

fgetc 0 Chr
sum+=Chr
sum=sum & 0xff
checkSum=256-sum
fseek 0 offset 0
fputc 0 checkSum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top