[Tutor] CRC calculation with python
Kent Johnson
kent37 at tds.net
Tue Feb 6 14:14:58 CET 2007
Johan Geldenhuys wrote:
> Hi all,
>
> I'm not a C++ expert at all and I would like to find out if somebody can
> explain to me how the statement below can be done in Python?
I suggest you Google "Python CRC" and find out how others have done
this, rather than trying to translate the code directly.
Kent
>
> """
> _uint16 ComCRC16(_uint8 val, _uint16 crc)
> {
> _uint8 i;
> _uint16 cval;
>
> for (i=0;i<8;i++)
> {
> if (((crc & 0x0001)^(val & 0x0001))!= 0) crc = (crc >> 1)^
> CCITT_POLY;
> else crc >>= 1;
> val >>= 1;
> }
> return crc
> }
>
> """
>
> Thanks
>
> Johan
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.25/669 - Release Date:
> 2007/02/04 09:58 PM
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list