[Tutor] CRC calculation with python

Johan Geldenhuys johan at accesstel.co.za
Tue Feb 6 13:31:16 CET 2007


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?
 
"""
_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
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070206/52a66788/attachment.htm 


More information about the Tutor mailing list