Velocity Reviews > CRC calculation

# CRC calculation

ALuPin
Guest
Posts: n/a

 07-02-2004
Hi,

I have found a piece of C code for checksum calculation
CRC16 ccitt.

Is that right?
How can I initialize crc?

#include <stdio.h>

int crc_1021(int data)
{

int x;

x = ((crc>> ^ data) & 0xff;
x ^= x>>4;
crc = (crc << ^ (x << 12) ^ (x <<5) ^ x;
crc &= 0xffff;

return(crc);

}

int main()

{
int crc
printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));
return 0;
}

Grumble
Guest
Posts: n/a

 07-02-2004
ALuPin wrote:

> I have found a piece of C code for checksum calculation
> CRC16 ccitt.
>
> Is that right?
> How can I initialize crc?

Errr. Where is your question about the C language?

Jack Klein
Guest
Posts: n/a

 07-04-2004
On 2 Jul 2004 04:23:19 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) (ALuPin) wrote in
comp.lang.c:

> Hi,
>
> I have found a piece of C code for checksum calculation
> CRC16 ccitt.
>
> Is that right?
> How can I initialize crc?
>
>
>
>
> #include <stdio.h>
>
> int crc_1021(int data)
> {
>
> int x;
>
> x = ((crc>> ^ data) & 0xff;
> x ^= x>>4;
> crc = (crc << ^ (x << 12) ^ (x <<5) ^ x;
> crc &= 0xffff;
>
> return(crc);
>
> }
>
> int main()
>
> {
> int crc

Change the line above to:

int crc = /* whatever initial value you want */

> printf("The CRC16-X25_ccitt of %d is %d. \n", crc, crc_1021(crc));
> return 0;
> }

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html

ALuPin
Guest
Posts: n/a

 07-05-2004
Grumble <(E-Mail Removed)> wrote in message news:<cc3jm3\$191\$(E-Mail Removed)>...
> ALuPin wrote:
>
> > I have found a piece of C code for checksum calculation
> > CRC16 ccitt.
> >
> > Is that right?
> > How can I initialize crc?

>
> Errr. Where is your question about the C language?

Hey,

if you do not want to help then SHUT UP.

Thank you very much.

Best regards

xarax
Guest
Posts: n/a

 07-05-2004
"ALuPin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Grumble <(E-Mail Removed)> wrote in message news:<cc3jm3\$191\$(E-Mail Removed)>...
> > ALuPin wrote:
> >
> > > I have found a piece of C code for checksum calculation
> > > CRC16 ccitt.
> > >
> > > Is that right?
> > > How can I initialize crc?

> >
> > Errr. Where is your question about the C language?

>
> Hey,
>
> if you do not want to help then SHUT UP.
>
> Thank you very much.
>
> Best regards

You are posting your question in the wrong

Mark McIntyre
Guest
Posts: n/a

 07-05-2004
On 5 Jul 2004 00:07:31 -0700, in comp.lang.c , (E-Mail Removed) (ALuPin)
wrote:

>Grumble <(E-Mail Removed)> wrote in message news:<cc3jm3\$191\$(E-Mail Removed)>...

>> Errr. Where is your question about the C language?

>
>if you do not want to help then SHUT UP.

You ask an offtopic question, get asked what your actual relevant question
is, and are rude? Thats very silly.

>Thank you very much.

Welcome.
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---