Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > CRC calculation

Reply
Thread Tools

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;
}
 
Reply With Quote
 
 
 
 
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?

 
Reply With Quote
 
 
 
 
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
 
Reply With Quote
 
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
 
Reply With Quote
 
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
group, so please take your own advice.


 
Reply With Quote
 
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>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.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 =---
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
String::CRC crc function returns incorrect result, why? `Zidane Tribal Perl 1 07-28-2007 08:01 PM
String::CRC crc function returns incorrect result, why? `Zidane Tribal Perl Misc 3 07-27-2007 11:41 AM
crc-8 and crc-16 code... Mamut C++ 5 02-22-2007 02:22 PM
CRC calculation mike7411@gmail.com Python 2 05-05-2006 10:50 AM
CRC polynomal calculation Runar Gjelsvik VHDL 2 04-29-2004 09:08 AM



Advertisments