igor1212 has asked for the wisdom of the Perl Monks concerning the following question:
I've tried every combination using digest::crc and string::crc, but I've got no correct crc value.
I've received a c function for crc calculation from my device vendor, but I need this in Perl.
C Function:
unsigned short crc_16_rec (char *pucData, unsigned short ucLen) { unsigned int i; unsigned char ucBit, ucCarry; unsigned short usPoly = 0x8408;//reversed 0x1021 unsigned short usCRC = 0; for (i = 0; i < ucLen; i++) { usCRC ^= pucData[i]; for (ucBit = 0; ucBit < 8; ucBit++) { ucCarry = usCRC & 1; usCRC >>= 1; if (ucCarry) { usCRC ^= usPoly; } } } return usCRC; }
Can somebody please help me with this, because I'm stuck here!
Best Regards!
Igor
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CRC 16
by BrowserUk (Patriarch) on Oct 08, 2012 at 08:21 UTC | |
|
Re: CRC 16
by moritz (Cardinal) on Oct 08, 2012 at 12:36 UTC | |
by BrowserUk (Patriarch) on Oct 08, 2012 at 12:42 UTC | |
by igor1212 (Novice) on Oct 08, 2012 at 15:11 UTC |