Announcement

Collapse
No announcement yet.

CRC-CCITT Checksum

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tom Hanlin
    replied
    Have you tried a Forum search? Seems like I may have seen this in the Source Code Forum.

    It shouldn't be hard to translate this to PowerBASIC, though. I gather it's from 16-bit
    C code, so the "unsigned short" translates as WORD, and "unsigned char" as BYTE. The ">>"
    operator means "SHIFT RIGHT", "^" is XOR, and "&" is AND. "*" is still *.

    (those spots that say "unsigned sort" are surely typos for "unsigned short").

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Leave a comment:


  • Matthias Kuhn
    started a topic CRC-CCITT Checksum

    CRC-CCITT Checksum

    Hi,

    has anyone a sample in PB how to program a 16-Bit CRC-CCITT
    Checksum.

    I´ve only a sample in c:

    unsigned sort crc;
    crc = 0;
    calc_crc( ID_H );
    calc_crc( ID_L );
    .
    .
    .
    calc_crc( <last databyte> );

    CRC_H = (unsigned char)(crc>>8);
    CRC_L = (unsigned char)crc;
    .
    .
    void calc_crc( unsigned char character )
    {
    unsigned sort crc_tmp;
    crc_tmp=(crc^character) & 0x0F;
    crc=(crc>>4)^(crc_tmp*4225);
    crc_tmp=(crc^(charcter>>4))& 0x0F;
    crc=(crc>>4)^(crc_tmp*4225)
    }

    Thanks for any help.

    Regards

    Matthias Kuhn

    ------------------
Working...
X