AnsweredAssumed Answered

vrf CheckSum

Question asked by VRFuser on Aug 16, 2007
Latest reply on Aug 16, 2007 by VRFuser
Dear All,

Oh, for a degree in computer science or better yet to be a full time programmer or drunk!

I am trying to get an instrument to work that needs a checksum using VEE, but I don't have much to go on other than the following from the manufacturer.

Communication is based on a standard RS232 port. All bytes are ASCII except the two CRC bytes used for a redundancy check. Each command starts with four bytes of command type, followed by a variable length value section. The two CRC bytes follow the value string and a carriage return ends the string. Each command string will vary in length but, can not exceed 26 bytes. 
Command String = {4 command bytes + variable length value + 2 CRC bytes + carriage return} < 26 bytes. 
Note: Some commands that request information to be sent back start 

The following is a C version of calculating the cc bytes. 
crc=0xffff; 
while(!(crcString [j]==0){ // loop through string and calc a crc until null char 
crc = crc ^ ((INT16U) (crcString [j] * 0x0100); 
for(i=0;i<8;i++){ 
if(crc & 0x8000) 
crc = (crc<<1)^0x1021; // prime number 
else 
crc = crc<<1; 

j++; 

if((crc & 0xff00)==0x0d00) crc +=0x0100; // increment if byte is carriage return 
if((crc & 0x00ff)==0x000d) crc +=0x0001; // increment if byte is carriage return 
if((crc & 0xff00)==0x0000) crc +=0x0100; // no zero bytes allowed 
if((crc & 0x00ff)==0x0000) crc +=0x0001; // no zero bytes allowed 

It will take me a week to figure this out and I would probably enjoy it but its well beyond my skill set and I am in a time-pinch. Any chance one of you experts has a VEE sumcheck program or can parse the above into VEE?

Any help would be much appreciated. Payment will be in virtual beer.

Best wishes,
Richard.


---
You are currently subscribed to vrf as: hua_jing@agilent.com
To subscribe please send an email to: "vrf-request@lists.it.agilent.com" with the word subscribe in the message body.
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list, email "vrf@agilent.com".
If you need help with the mailing list send a message to
"owner-vrf@it.lists.it.agilent.com".
Search the "unofficial vrf archive" at "http://www.vrfarchive.com/vrf_archive".
Search the Agilent vrf archive at "http://vee.engineering.agilent.com".  

Outcomes