Computing CRC for DC command?

by chrismacgregor last modified Jan 23, 2008 12:31 AM
Up to Software

Computing CRC for DC command?

Posted by chrismacgregor at January 22. 2008

Hi.  I have written some software to control one of your Vector devices, and all seems to be working fine.  I'm trying to add a function to download data stored on the device, and I can't figure out how to compute a CRC to match the one produced by the DC command.  I've tried using the same code that successfully computes a checksum to match those used in the various data packets, but I note that you refer to those as checksums but the DC command as a CRC.

How exactly is that CRC computed?

Thanks,
    Chris

Current state: Being created

Re: Computing CRC for DC command?

Posted by Øistein Hurum at January 22. 2008

Hello Chris,

Here is the CRC code:

unsigned short CPdComm::CRC(unsigned short hCRC,char *pcBuf,int nLen)
{
   int i;
   while (nLen--) {
      hCRC ^= (unsigned short) (*pcBuf++)<<8;
      for (i=0; i<8; ++i) {
         if (hCRC & 0x8000)
            hCRC = (hCRC << 1) ^ 0x1021;
         else
            hCRC <<= 1;
      }
   }
   return hCRC;
}

Best regards,
Oistein

Current state: Being created

Re: Computing CRC for DC command?

Posted by chrismacgregor at January 23. 2008

Works great - thanks very much!

    Chris

Current state: Being created
Powered by Ploneboard
Document Actions
Log in


Forgot your password?
New user?