1 |
//If big-little endian problem: switch tmp1&0xFF00 + tmp2&0x00FF -> |
2 |
// tmp1&0x00FF + tmp2&0xFF00 |
3 |
#include <stdio.h> |
4 |
#include "ACphysics.h" |
5 |
|
6 |
int ACphysics(unsigned short* datapointer,struct datastruct* physicspointer) |
7 |
{ |
8 |
|
9 |
*physicspointer=physicsdata; |
10 |
|
11 |
//look for header AC11, then cut out the event to a temp buffer |
12 |
while(found==0) |
13 |
{ |
14 |
tmp1=*datapointer; |
15 |
tmp2=*(datapointer+1); |
16 |
if(tmp1==0x11AC) |
17 |
{ |
18 |
found=1; |
19 |
for(i=0;i<64;i++) |
20 |
{ |
21 |
buffer[i]=*datapointer; |
22 |
datapointer++; |
23 |
} |
24 |
tmp1=0x0000; |
25 |
} |
26 |
if((tmp1&0xFF00) + (tmp2&0x00FF)==0xAC11) |
27 |
{ |
28 |
found=1; |
29 |
for(i=0;i<64;i++) |
30 |
{ |
31 |
buffer[i]=(tmp1&0xFF00) + (tmp2&0x00FF); |
32 |
datapointer++; |
33 |
tmp1=tmp2; |
34 |
tmp2=*(datapointer+1); |
35 |
} |
36 |
} |
37 |
datapointer++; |
38 |
} |
39 |
|
40 |
//check header2 |
41 |
if(buffer[1]==0xAC22) |
42 |
err=0; |
43 |
else |
44 |
err=1; |
45 |
|
46 |
//Fill physicsdata from buffer |
47 |
for(i=0;i<2;i++) physicsdata.header[i]=buffer[i]; |
48 |
physicsdata.status=buffer[2]; |
49 |
physicsdata.hitmap=buffer[3]; |
50 |
for(i=0;i<6;i++) physicsdata.regist[i]=buffer[4+i]; |
51 |
for(i=0;i<16;i++) physicsdata.shift[i]=buffer[10+i]; |
52 |
for(i=0;i<16;i++) physicsdata.counters[i]=buffer[26+i]; |
53 |
for(i=0;i<8;i++) physicsdata.coinc[i]=buffer[42+i]; |
54 |
physicsdata.trigg=buffer[50]; |
55 |
for(i=0;i<2;i++) physicsdata.clock[i]=buffer[51+i]; |
56 |
for(i=0;i<2;i++) physicsdata.temp[i]=buffer[53+i]; |
57 |
for(i=0;i<8;i++) physicsdata.DAC[i]=buffer[55+i]; |
58 |
physicsdata.CRC=buffer[63]; |
59 |
|
60 |
return err; |
61 |
|
62 |
} |
63 |
|