avr-libc-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect


From: Weddington, Eric
Subject: Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect
Date: Tue, 11 Dec 2012 15:50:09 +0000


> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden On
> Behalf Of Joerg Wunsch
> Sent: Tuesday, December 11, 2012 8:39 AM
> To: address@hidden
> Cc: mojo
> Subject: Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect
> 
> All the functions of this header file (_crc16_update which once
> started the file but uses the "IBM-CRC-16" polynomial,
> _crc_xmodem_update, _crc_ccitt_update, and finally
> _crc_ibutton_update) have been deliberately chosen to lie in the
> implementation namespace so they don't collide with the application
> namespace.
> 
> Thus, an application could do something like this:
> 
> #if defined(__AVR__) && defined(__GNUC__)
> #  define crc_ccitt_update(c, v) _crc_ccitt_update(c, v)
> #else
> inline uint16_t crc_ccitt_update(uint16_t crc, uint8_t data)
> {
>     data ^= crc & 0xff;
>     data ^= data << 4;
> 
>     return ((((uint16_t)data << 8) | ((crc & 0xff00) >> 8))
>             ^ (uint8_t)(data >> 4)
>             ^ ((uint16_t)data << 3));
> }
> #endif

Then how about a name that is more meaningful & intuitive?

>From experience, you can tell users all day long in the documentation, and in 
>the FAQ, to use _crc_xmodem_update() and they still won't get it.

Can we create an alias macro? _crc_xmega_ccitt_update()? Then put the 
explanation in the docs.

We need to support the xmega users better. If they're getting easily confused, 
then we need to help.

Eric



reply via email to

[Prev in Thread] Current Thread [Next in Thread]