[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-libc-dev] [RFC,patch] xmodem-crc
From: |
Theodore A. Roth |
Subject: |
Re: [avr-libc-dev] [RFC,patch] xmodem-crc |
Date: |
Mon, 10 Nov 2003 11:48:49 -0800 (PST) |
On Mon, 10 Nov 2003, E.Weddington wrote:
> > Hi,
> >
> > Attached is a patch for avr/crc.h which adds dox and the
> xmodem crc
> > function.
> >
> > Any objections to committing this to HEAD and 1.0?
> >
> > Ted Roth
> >
>
> 1. This would add a new function (API) so shouldn't it only
> go into HEAD according to policy?
Adding functionality is OK. Changing existing functionality is BAD.
Note that vfprintf_P and vfscanf_P have already been released as
extensions to the API in 1.0.1.
>
> 2. Your "xmodem crc" polynomial of x^16+x^12+x^5+1 (for
> easier notation: [16,12,5,1]) is also more commonly known
> as the CRC-CCITT (Comité Consultatif International
> Télégraphique et Téléphonique) and is used in many
> different protocols, not just XMODEM. I would suggest
> renaming the function to reflect that it is the CCITT CRC,
> as most people (I would think), when they look for a CRC
> function, would be looking for a "CCITT" CRC.
Actually, crc-xmodem is not the same as crc-ccitt. They both use the
same polynomial, but ccitt shifts in the LSB first and xmodem shifts in
the MSB first. Thus, you get different incompatible results.
The test code I posted on friday shows expected values. Here they are
for both xmodem and CCITT:
Input: xmodem: CCITT:
'M' 0x9969 0x99e1
'T' 0x1a71 0x14a1
'THE' 0x1e0a 0x7d8d
'THE,QUICK,BROWN,FOX,0123456789' 0x0498 0x7dc5
Those values where taken from Crenshaw's article.
>
> I'm getting some of this info from _Numerical Recipes in
> C_, 2nd edition by Press, Teukolsky, Vetterling, and
> Flannery.
Look at the table on page 898. All of the protocols in that table use
the same polynomial.
Now that I understand the algorithm, it's rather trivial to get the
rules for generating the CRC and then slightly less trivial to write the
asm. I've already considered adding a few more commonly used CRCs when I
get some more time.
For reference, the openoffice spreadsheet I used to work out the XOR
rules is here:
http://www.openavr.org/misc/Crc16-rules.sxc
Ted Roth