[Tutor] CRC calculation with python

Johan Geldenhuys johan at accesstel.co.za
Wed Feb 7 06:41:10 CET 2007


Thanks for all the replies,

I got this code from a protocol spec that I must use for communications to a
RS232 interface and this the way they calculate the CRC for the data in the
packet.

I have never done any C programming and thought that somebody in this list
may be able to assist.

The idea that I get from the replies is that I should rather use a Python
module for calculating the CRC, thanks Dave for the suggestion. I'll rather
go and look at that than to use a translated C code snippet.

Every now and again I come across C code that is compared with Python code
and since I don't know C, I can't follow the comparison. I never use C in my
work, so for me to go and study the syntax and code layout is something I
wouldn't really use a lot.

Johan

 

-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On Behalf
Of Dave Kuhlman
Sent: 06 February 2007 07:28 PM
To: tutor at python.org
Subject: Re: [Tutor] CRC calculation with python

On Tue, Feb 06, 2007 at 12:10:36PM -0500, Chris Calloway wrote:
> First, you need to find the preprocessor define for CCITT_POLY. The 
> code is incomplete without it.
> 
> Second, where did this code come from? It defines an unused local 
> named cval, which will usually cause at least a compilation warning.
> 
> This looks like a snippet, not a complete CCITT CRC calculation.

Also, see the crcmod module:

    http://crcmod.sourceforge.net/

But, the README that comes with crcmod recommends the md5 module in the
Python standard library.

Dave


--
Dave Kuhlman
http://www.rexx.com/~dkuhlman
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor

--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.25/669 - Release Date: 2007/02/04
09:58 PM
 

-- 
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
 



More information about the Tutor mailing list