Computing CRC for DC command?
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
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

