1 |
/**************************************************************************** |
2 |
* F i l e D a t a |
3 |
* $Id: crc.c,v 1.4 2004/05/20 16:03:52 faber Exp $ |
4 |
* $Revision: 1.4 $ |
5 |
* $Date: 2004/05/20 16:03:52 $ |
6 |
* $RCSfile: crc.c,v $ |
7 |
* |
8 |
**************************************************************************** |
9 |
* S W D e v e l o p m e n t E n v i r o n m e n t |
10 |
* |
11 |
* $Author: faber $ |
12 |
* : |
13 |
**************************************************************************** |
14 |
* U p d a t i n g |
15 |
|
16 |
* $Log: crc.c,v $ |
17 |
* Revision 1.4 2004/05/20 16:03:52 faber |
18 |
* ACQ flow dev continuing |
19 |
* |
20 |
* Revision 1.3 2004/05/20 12:24:44 faber |
21 |
* getchar bugfixed |
22 |
* |
23 |
* Revision 1.2 2004/05/20 10:47:17 faber |
24 |
* printf stderr |
25 |
|
26 |
* Revision 1.1 2004/02/26 16:30:07 faber |
27 |
* crc.c added |
28 |
* |
29 |
* Revision 1.1 2003/10/03 16:12:26 faber |
30 |
* *** empty log message *** |
31 |
* |
32 |
* |
33 |
*****************************************************************************/ |
34 |
|
35 |
|
36 |
//#include "CM_Common_INFN.h" |
37 |
#include "DAQ_IDAQ_INFN.h" |
38 |
#include <stdio.h> |
39 |
|
40 |
DAQ_DECLBUF(B,1024*1024); |
41 |
|
42 |
int main(void) { |
43 |
int c; |
44 |
unsigned short crc=0; |
45 |
status_code s; |
46 |
DAQ_BUFFER_INIT(B); |
47 |
// fprintf(stderr,"\n-------\n "); |
48 |
while( (c=getchar()) != EOF) { |
49 |
if(B.len < B.size) { |
50 |
B.buf[B.len++]=c; |
51 |
/* |
52 |
fprintf(stderr,"%02X ",c); |
53 |
if(B.len % 16 == 0) { |
54 |
fprintf(stderr,"\n"); |
55 |
} |
56 |
*/ |
57 |
} |
58 |
else |
59 |
return 1; |
60 |
} |
61 |
// fprintf(stderr,"\n [Size: %d]\n",B.len); |
62 |
s=DAQ_Compute_CRC16(&B); |
63 |
if(s!=CM_RC_SUCCESSFUL) |
64 |
return s; |
65 |
s=DAQ_Compute_CRC8(&B); |
66 |
if(s!=CM_RC_SUCCESSFUL) |
67 |
return s; |
68 |
printf("%02X %04X",B.crc8,B.crc16); |
69 |
return 0; |
70 |
} |